mysql_select_db supplied argument is not a valid MySQL-Link resource
I require_once("includefile.php"); that contains a mysql_connect() function that returns a valid Resource ID.
I have a mysql_select_db() of:
$OneSitHomeDB = mysql_connect($hostname_OneSitHomeDB, $username_OneSitHomeDB, $password_OneSitHomeDB) or die(mysql_error());
Note that the call and arguments are printed as part of the die() function. What is returned is:
mysql_select_db($database_OneSitHomeDB, $OneSitHomeDB) or die(mysql_error() . " mysql_select_db($database_OneSitHomeDB, $OneSitHomeDB) " . __FILE__ . " : " . __LINE__);
Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in c:\Inetpub\wwwroot\OnesitHome\php-includes\_autoCache.php on line 56
mysql_select_db(1sitHomeDB, Resource id #4) c:\Inetpub\wwwroot\OnesitHome\php-includes\_autoCache.php : 56
As you can see from the output, the Resource ID is 'Resource id #4' which sure looks like a valid resource ID to me! I've tried restarting mySQL, restarting the webservice, etc. This same code has worked reliably (same function) in another application. But I can't figure out what's wrong or how to solve it.
It seems to magically start working sometimes and then dies again from this error. But I can't go forward with the error.
I have noticed that the page that uses this will sometimes have an "transferring data from pdx1" in the satus bar (which it doesn't seem like it should since the page is complete) so I'm not sure if that has anything to do with it. When I look at the connections in mysqlAdministrator it usually shows 2 but never more than 4.
What happens when you do the resource implicitly in the call? IE just use mysql_select_db($database_OneSitHomeDB)
I've never really seen what my resources are called, so I don't know if that's what it's supposed to look like...
"do this or die()" sooo redundant, connecting to MySQL < 4.1 is a two step process
$db = @mysql_connect('localhost', 'root', '');
if(!$db || !@mysql_select_db('dbname', $db))
die('unable to connect to mysql server: ' . mysql_error());
Originally Posted by ShrineDesigns
he is doing a 2 step process. and fyi
works perfectly fine, system's mysql 4.0.23
$link = mysql_connect('server:3306', 'username', 'password') or die('Could not connect: ' . mysql_error());
$db_selected = mysql_select_db('content', $link) or die ('Error while connecting to database: ' . mysql_error());
Problem seems to be with $_SESSION variables getting lost
I'm going to post a separate question in this group to address this problem. Not sure I understand what's going on.
oh i see what the problem is...
database, table, and column names MUST begin with a character not a numerial (sameas the rule for php variable names, if i remember correctly)
Last edited by ShrineDesigns; 10-19-2005 at 12:57 AM.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)