note 84159 added to function.mysql-ping

From: Date: Tue, 01 Jul 2008 14:31:15 +0000
Subject: note 84159 added to function.mysql-ping
Groups: php.notes 
Request: Send a blank email to php-notes+get-141037@lists.php.net to get a copy of this message
Thanks to Dustin Hawkins i made this function, maybe can be usefull for your scripts: <?php function connect_mysql() { global $CONN, $MYSQL; if (!$CONN) { $CONN = @mysql_connect ($MYSQL["HOST"], $MYSQL["USER"], $MYSQL["PASS"]) or die ("error on connecting: " . mysql_error()); @mysql_select_db ($MYSQL["NAME"], $CONN) or die ("error on selecting database: " . mysql_error()); } else { if (!@mysql_ping($CONN)) { mysql_close($CONN); $CONN = @mysql_connect ($MYSQL["HOST"], $MYSQL["USER"], $MYSQL["PASS"]) or die ("error on re-connecting: " . mysql_error()); @mysql_select_db ($MYSQL["NAME"], $CONN) or die ("error on selecting database: " . mysql_error()); } } } //call this function before every mysq_query(); and everything goes right. ?> $MYSQL is an array with all configs needed in order to connect ---- Server IP: 92.48.74.199 Probable Submitter: 84.201.159.234 ---- Manual Page -- http://www.php.net/manual/en/function.mysql-ping.php Edit -- https://master.php.net/note/edit/84159 Del: integrated -- https://master.php.net/note/delete/84159/integrated Del: useless -- https://master.php.net/note/delete/84159/useless Del: bad code -- https://master.php.net/note/delete/84159/bad+code Del: spam -- https://master.php.net/note/delete/84159/spam Del: non-english -- https://master.php.net/note/delete/84159/non-english Del: in docs -- https://master.php.net/note/delete/84159/in+docs Del: other reasons-- https://master.php.net/note/delete/84159 Reject -- https://master.php.net/note/reject/84159 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#141037) next »