Re: Sanitizing potential MySQL strings with no database connection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2009/10/19 Kim Madsen <php.net@xxxxxxx>:
> 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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux