Re: Sanitizing potential MySQL strings with no database connection
| From: | Kim Madsen | Date: | Mon, 19 Oct 2009 15:54:56 +0000 |
| Subject: | Re: Sanitizing potential MySQL strings with no database connection | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-299052@lists.php.net to get a copy of this message | ||
Dotan Cohen wrote on 2009-10-18 21:21:
I thought that one could not test if a database connection is established or not, this is the most relevant thing that I found while googling that: http://bugs.php.net/bug.php?id=29645from http://www.php.net/manual/en/function.mysql-connect.php $link = mysql_connect('localhost', 'mysql_user', 'mysql_password'); if (!$link) {
die('Could not connect: ' . mysql_error());
}
So just test if $link is available
All the connections are to MySQL databases, but to _different_ MySQL databases on the same host.Would't this solve you problem? $link1 = mysql_connect('localhost', 'mysql_user1', 'mysql_password'); $link2 = mysql_connect('localhost', 'mysql_user2', 'mysql_password'); if($link1) { etc... or I would say that your "different scripts" should require different db connection files.