• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 328
  • Last Modified:

supplied argument is not a valid MySQL-Link resource error

I'm getting an error on line 11, saying Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource. What does this mean?

$con = mysql_connect("localhost","","");
	if (!$con)
 	 die('Could not connect: ' . mysql_error());

	mysql_select_db("", $con);

$query = mysql_query("SELECT description, cross_streets, title, town, feeornofee, lease, phone, contact, office, email, rent FROM apartments WHERE description LIKE '%$search%' ¦¦ cross_streets LIKE '%$search%' ¦¦ title LIKE '%$search%' ¦¦ town LIKE '%$search%' ¦¦ feeornofee LIKE '%$search%' ¦¦ lease LIKE '%$search%' ¦¦ phone LIKE '%$search%' ¦¦ contact LIKE '%$search%' ¦¦ contact LIKE '%$search%' ¦¦ office LIKE '%$search%' ¦¦ email LIKE '%$search%' ¦¦ rent LIKE '%$search%'", $db);

if ($query) 
echo "<table width=100% border=0 cellpadding=0 cellspacing=5 class=border_playlist_table><tr>";

while ($myrow = mysql_fetch_array($query)) { // Begin while 
$title = $myrow["title"]; 
$town = $myrow["town"];
$contact = $myrow["contact"]; 
$office = $myrow["office"]; 
$phone = $myrow["phone"]; 
$rent = $myrow["rent"]; 
echo "<tr class=sub_1><td colspan=4>$title : $town</td></tr> 
<tr bgcolor=#55556F><td><p><a href=$url target=_blank>$url</a></p></td> 
<tr bgcolor=#55556F><td colspan=4>$office</td></tr> 
<tr bgcolor=#55556F><td colspan=4>$phone</td></tr> 
<tr><td colspan=4>&nbsp;</td></tr>"; 
} // end while 
echo "</tr></table>"; 
echo "Search string is empty. <br> Go back and type a string to search"; 

Open in new window

1 Solution
Hey. Did you ever try to insert you database name on "mysql_select_db("  your Database name  ", $con);" . if it's not work I think some value of your select seem don't have any value. try to check value again in mysql command.

genesisvhAuthor Commented:
I have put in the name I just excluded it here.
Dave BaldwinFixer of ProblemsCommented:
You have '$db' on line 11 but you have '$con' on line 3.  They should match.  '$con' is the 'Resource ID' from the connection.
DaveBaldwin: Oh. It's true. Why I can't notice it. lol Oh It's a small mistake but make more trouble. LOL
Ray PaseurCommented:
You don't need the $db variable at all in the query.

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now