Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- mysql_connect succeeds but select_db fails
February 20, 2005, 12:16 pm
rate this thread
This is very strange.
I'm running MySQL 4.1.10, and php 4.3.10, on a FreeBSD 4.10 box. The
database has been created, and permissions are set right. I can access
the database from bin/mysql without a problem, too, using -uweb
$connection = @ mysql_connect("localhost", "web", "blahblahblah") ||
printf("conn = %d<p>", $connection);
mysql_select_db("somedb", $connection) || die (mysql_error() );
conn = 1
Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link
resource in /usr/local/apache8001/htdocs/scratch/index.php on line 7
I am so at a loss, and could use any help you could offer.
Re: mysql_connect succeeds but select_db fails
Actually you probably want the 'or' operator - not ||. There's a subtle
difference related to operator precedence.
$connection = @mysql_connect("localhost", "web", "blahblahblah")
Should have been something like 'MySQL Link Resource #1'- but you'd have to
use %s in the format string anyway.
<http://www.andyhsoftware.co.uk/space Space: disk usage analysis tool