faqts : Computers : Programming : Languages : PHP : Database Backed Sites : MySQL

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

29 of 58 people (50%) answered Yes
Recently 3 of 10 people (30%) answered Yes

Entry

What does the error 'Warning: 1 is not a valid MySQL-Link resource' mean?

Jan 18th, 2002 16:43
Eric Benoit, James Moore, Matt Gregory, Joshua Ariizumi, Nathan Wallace,


This probably means that you are using a result index where an link 
index is expected.  Check your syntax.
example which gives this error: (assuming that MyDatabase exists)
$myconnection = mysql_connect("localhost", "user", "pass");
$Query = "SELECT * FROM MyDatabase";
$resultset = mysql_query($Query);
$numrowsaffected = mysql_affected_rows($resultset);
//this is wrong because mysql_affected_rows expects the link index 
//not the result index.  Fix the error by changin it to:
$numrowsaffected = mysql_affected_rows($myconnection);
Also, it is possible that the database you are referring to in your 
connection string is wrong or your database is named differently to 
what you refer to in your connection string.
You may also encounter this error (and I found out the hard way) when 
your table doesn't have any index...took me awhile to figure this one 
out at the time, wish I know about this site then! :)