
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.mysqladmin flush-hosts
<?php
if(isset($my_db_connection)){
mysql_close($my_db_connection);
}
?>
$my_db_connection = mysql_connect(DB_SERVER,DB_USER,DB_PASS);
<link rel="shortcut icon" href="/favicon.ico">
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;
}
echo smiley("w00t That makes me so happy! :)");