i3m digital media studio archive blog articles i3m digital media studio archive blog articles i3m digital media studio last ten postings to the blog
  • MySQL rectify error 1129?

  • July 1, 2009, 7:58 am
  • MySQL server reporting too many hosts?


  • How to fix MySQL error 1129 in a flush!A MySQL server has a finite number of connections that it will allow, which acts as a safety mechanism against potentially harmful actions. During usual interaction with the server a script will make a connection, run its query and return the query results. The script should also disconnect from the MySQL server when it’s finished to free up one of the limited number of connections that the server will allow. Not doing so can eventually cause an overflow error, which will often not manifest itself until much later in the development process or worse still after client delivery.

    How to rectify a MySQL error 1129 ‘Too many hosts’ overflow.

    Assuming that your MySQL server is not being maliciously attacked a simple command entered at the command line is enough to flush the hosts cache. If you do not have access to the command line then you will need to get an Admin at your webhost to execute this for your. The command is:

    mysqladmin flush-hosts


    Once you have flushed your MySQL server should take off its tin hat and step out of the bunker; metaphorically speaking anyway. Again assuming that you have a hosts cache overflow through some result other than a malicious testing the system, you are going to need to fix whatever caused the problem so it doesn’t keep occurring.

    Best Practice for disconnecting from the MySQL server

    One way of insuring that you disconnect from the MySQL server on every occasion is to add a small script to the footer element of your page (If your site is too small to need you to include or require a footer then you can just add this to each page by hand). The code itself is very basic PHP but means you can eliminate your pages causing any host errors and rest assured you have disconnected from the MySQL server too.

    <?php
    if(isset($my_db_connection)){
    mysql_close($my_db_connection);
    }
    ?>


    Where you have originally connected to the database using something resembling:

    $my_db_connection = mysql_connect(DB_SERVER,DB_USER,DB_PASS);

  • 'Assuming that your MySQL server is not being maliciously attacked a simple command entered at the command line is enough to flush the hosts cache.'
  • Posted in: programming | comments: off | filters: on (remove filter)
  • subscribe to the i3m rss feed subscribe | Bookmark and Share
  • back to top
  • Generate favicon files for free

  • June 26, 2009, 5:59 pm
  • Present your logo in your browser URL


  • A very quick note today as we are currently redeveloping the istockcreative.com site (feel free to head on over and take a look at the new version 2, web2.0 update but be aware that this is still work in progress!).

    So we needed a new favicon


    Anyway there are a million and one sites out there offering to generate your favicon’s for free but many are poor and even more do not work at all. So to save you the bother we recommend the Dynamic Drive site, which is where we generate our favicons.

    For those whose don’t know a favicon is the logo or symbol that appears by your URL in the browser window of your chosen browser. If a site does not have one then usually the browsers default logo is displayed instead. Anyway the image is a small (16 x 16 pixel) brand icon image that is uploaded to the root of your web server and is called in html using the following line in your section

    <link rel="shortcut icon" href="/favicon.ico">


    There, no excuses for not having one now :D
  • 'A favicon is a good way to brand your site and increase it's prominence in your visitor's bookmark menu.'
  • Posted in: programming | comments: off | filters: on (remove filter)
  • subscribe to the i3m rss feed subscribe | Bookmark and Share
  • back to top
  • PHP Smileys & Emoticons for your blog

  • May 7, 2009, 5:59 pm
  • Automatically add smileys & emoticons your blog or text


  • Unless you’re stuck in a vacuum smileys and emoticons are no big news and have been around for some time now. For those who have just dropped in from another planet the smiley was a text based way of letting readers know how you were feeling. It originated on Bulletin Boards as a way a showing reading the mood behind comments and soon spread to SMS messaging on mobile cell phones where it captured the minds of the masses. As technology developed so did the smiley and the graphic smiley, or emoticons, soon appeared. With MSN Messenger/Live Messenger the emoticon soon entered the mainstream and if your thirty five or under the chances are it’s a familiar way of expressing yourself in text based media

    So you’ve written a blog, or are inviting comments from visitors to your site? Wouldn’t emoticons be a useful addition to your scripts? We thought so and are currently developing our in house blog system to automatically scan posts for smileys and convert them over to graphical emoticons on screen. We thought we would share the basics with you but please note this is an introduction only. Something for you to take away, add and amend as you see fit.

    Okay, let’s get started. You can certainly create your own emoticons but there are plenty of free sets available if you do a quick online search. So go get a set and come right back!

    Now, the i3m emoticons are 20x20 and you may find that some in a set are not always the same size. So it’s over to Photoshop or GIMP (Free image manipulation software) for a bit of image manipulation first. When you have them all the correct size then upload them to your web server in a convenient directory. For the example we will use the directory ‘image’.

    Now here’s the PHP function to read a string, look for smileys and then replace them with the graphical emoticons that we saved in our image directory:

    function smiley($str){
    //smileys to check for
    $smiles=array(
    ":)",":-)",":D",":-D",";)",";-)",":O",
    ":-O",":P",":-P","w00t","8)","8-)",":S",
    ":s","\:\(","\;\(","\|\)",":@"
    );
    // replace with emoticons
    $replacements=array(
    "<img src="http//yourwebsite.com/image/smile.gif" width="20" height="20" title="happy smiley" />",
    "<img src="http//yourwebsite.com/image/smile.gif" width="20" height="20" title="happy smiley" />",
    "<img src="http//yourwebsite.com/image/biggrin.gif" width="20" height="20" title="big grin smiley" />",
    "<img src="http//yourwebsite.com/image/biggrin.gif" width="20" height="20" title="big grin smiley" />",
    "<img src="http//yourwebsite.com/image/wink.gif" width="20" height="20" title="winking smiley" />",
    "<img src="http//yourwebsite.com/image/wink.gif" width="20" height="20" title="winking smiley" />",
    "<img src="http//yourwebsite.com/image/ohmy.gif" width="20" height="20" title="oh my smiley" />",
    "<img src="http//yourwebsite.com/image/ohmy.gif" width="20" height="20" title="oh my smiley" />",
    "<img src="http//yourwebsite.com/image/tongue.gif" width="20" height="20" title="tongue smiley" />",
    "<img src="http//yourwebsite.com/image/tongue.gif" width="20" height="20" title="tongue smiley" />",
    "<img src="http//yourwebsite.com/image/w00t.gif" width="20" height="20" title="w00t smiley" />",
    "<img src="http//yourwebsite.com/image/roll.gif" width="20" height="20" title="roll eyes smiley" />",
    "<img src="http//yourwebsite.com/image/roll.gif" width="20" height="20" title="roll eyes smiley" />",
    "<img src="http//yourwebsite.com/image/huh.gif" width="20" height="20" title="huh smiley" />",
    "<img src="http//yourwebsite.com/image/huh.gif" width="20" height="20" title="huh smiley" />",
    "<img src="http//yourwebsite.com/image/sad.gif" width="20" height="20" title="sad smiley" />",
    "<img src="http//yourwebsite.com/image/crying.gif" width="20" height="20" title="crying smiley" />",
    "<img src="http//yourwebsite.com/image/sleep.gif" width="20" height="20" title="sleep smiley" />",
    "<img src="http//yourwebsite.com/image/mad.gif" width="20" height="20" title="mad smiley" />",
    );
    for($i=0;$i < sizeof($smiles);$i++){
    $str=eregi_replace($smiles[$i], $replacements[$i], strtolower($str));
    }
    return $str;
    }

    The code is fairly self explanatory. Our PHP function is passed a string which is then looks for any of the smileys we have defined in the array $smiles and replaces it with the corresponding image listed in the array $replacements. As smileys can be either lower or upper case we always convert our smiley to lower case when checking. The only other thing to note is that different people write smileys different ways so, for example, our script looks for the two character :) and three character :-) versions. The list of smileys is by no means exhaustive but covers the twelve most popular in our opinion.

    To use the function simply add your string to the function call and voila, instant emoticons!

    echo smiley("w00t That makes me so happy! :)");


    This should give you an output of:
    That makes me so happy!
  • 'For those who have just dropped in from another planet the smiley was a text based way of letting readers know how you were feeling.'
  • Posted in: programming | comments: off | filters: on (remove filter)
  • subscribe to the i3m rss feed subscribe | Bookmark and Share
  • back to top
  • Flash SWFObject and CSS z-index

  • April 1, 2009, 11:50 am
  • When updating the i3m site today we inserted a new flash object (.swf) into our page unaware that by default the flash player assumes the object to always be on top of the other page elements. This meant that the Javascript elements that dynamically appear suddenly disappeared under the flash area! Playing around with the CSS z-index of other elements within the page was ignored too.

    So, if you’ve experienced this problem then look no further. You’re answer is the flash object parameter ‘wmode’. So inside your flash object you should still have something that reads:

    <param name="movie" value="myimage.swf" />

    If you add the line:

    <param name="wmode" value="opaque" />

    Then voila, this should solve your problems. We successfully checked this fix in Internet Explorer 7, Safari, Opera 9.6 and Firefox.
  • 'by default the flash player assumes the object to always be on top of the other page elements'
  • Posted in: programming | comments: off | filters: on (remove filter)
  • subscribe to the i3m rss feed subscribe | Bookmark and Share
  • back to top
  • SOAP XML updates now working

  • March 30, 2009, 4:45 pm
  • Earlier this month with blogged our intention to do some experiments with SOAP XML data transfer using the NUSOAP code for PHP. We are pleased to say that after some lengthy development sessions we now have SOAP services running on our istockcreative server, offering the latest image update information in the form of SOAP API’s.

    The latest images info that you see on this page are loaded and updated using the code. We hope to develop more SOAP API’s to offer greater services to members in future.
  • 'We hope to develop more SOAP API’s to offer greater services to members in future. '
  • Posted in: programming | comments: off | filters: on (remove filter)
  • subscribe to the i3m rss feed subscribe | Bookmark and Share
  • back to top
  • SOAP suds for istockcreative!

  • March 9, 2009, 9:36 pm
  • We recently had to bring our sister resource site (istockcreative.com) down for a week while we carried out some essential maintenance work on both the hardware platform and the code. Thanks to all of the members for their patience and we are now back online with no loss of data or service.

    The site will see extensive development during the second quarter of 2009 and this starts with some data sharing between the main i3m site and istockcreative, which will allow an overview of latest developments on istockcreative here on the main i3m portal. This will use SOAP and XML technology base on the popular NuSOAP scheme. Click here to get your free copy of the NuSOAP PHP code. In true i3m style we will be publishing behind the scenes insights into the use of SOAP, NuSOAP and XML technologies in client to server data relationships.
  • 'In true i3m style we will be publishing behind the scenes insights into the use of SOAP, NuSOAP and XML technologies in client to server data relationships.'
  • Posted in: programming | comments: off | filters: on (remove filter)
  • subscribe to the i3m rss feed subscribe | Bookmark and Share
  • back to top
  • Error 405 caused by bad PHP POST

  • September 14, 2008, 2:11 pm
  • Sometimes it's the simplest things!Ever had one of those programming days? A recent project through out an unusual server error (Error 405) from one of our test platforms and it proved to be one of those problems! The error was caused by a PHP POST command and initially we thought it was an .htaccess issue. Despite much research, advising all kinds of cures, our 405 error was caused quite simply by a typo! The reason for going to blog with this error? Well, not one posting out there suggested checking that your script is actually POSTing to a valid and correct filename! An apt reminder that quite often the simplest answer is the answer.
  • 'Just because the scripts are getting more complicated doesn't mean that the errors are!'
  • Posted in: programming | comments: off | filters: on (remove filter)
  • subscribe to the i3m rss feed subscribe | Bookmark and Share
  • back to top