Jump to content

[SOLVED] query errors when accessing table


Yammyguy

Recommended Posts

267 function article_query(){
268	 $project = $_POST["project"];
269	 $keyword = $_POST["keyword"];
270    $sql = ("SELECT * FROM mag_art_desc WHERE article = '$project' AND keywords LIKE '%$keyword%'");
271	 echo'<ol>';
272	 while($mags = mysql_fetch_array($sql)){
273		 echo'<li><b>'.$row[2].'</b> As found in '.$row[3];	
274	 }
275  	 echo'</ol>';
276 }

 

I've put the line numbers in my code so you can see where the error is claiming issues...

 

here's the error I'm getting:

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/article/index.php on line 272

 

I've copied and pasted the code as is into phpMyAdmin (replacing the variables with the proper values, of course) and the query executes exactly as I want.  But since I've copied it into my code here - it just errors out.

 

Any help would be VERY MUCH appreciated!

Change

 

$sql = ("SELECT * FROM mag_art_desc WHERE article = '$project' AND keywords LIKE '%$keyword%'");

 

to

 

$sql = mysql_query("SELECT * FROM mag_art_desc WHERE article = '$project' AND keywords LIKE '%$keyword%'");

 

just forgot the function name

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.