Re: Sanitizing potential MySQL strings with no database connection

From: Date: Mon, 19 Oct 2009 21:02:35 +0000
Subject: Re: Sanitizing potential MySQL strings with no database connection
References: 1 2 3 4 5 6 7 8  Groups: php.general 
Request: Send a blank email to php-general+get-299075@lists.php.net to get a copy of this message
2009/10/19 Kim Madsen <php.net@emax.dk>: > 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=29645 > > from 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 > I need to know if there is _any_ connection available, not a specific connection. In one script it may be $link but in another $connection. >> 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. > Of course they connect differently, each to a different database (all on localhost). -- Dotan Cohen http://what-is-what.com http://gibberish.co.il

« previous php.general (#299075) next »