Jump to content

problem changing sql query in php script


slashpine

Recommended Posts

I am not a php coder (just a hack) so I hope someone can see fit to offer some suggestions on how I can get this to work for me...

 

The script queries a database for business listings in a particular county...the user clicks a category and the listings are displayed (see array)

 

I would like to diversify this script to query the database to return the listings of a selected category BUT...only for a particular city...

 

Here is the existing code that works:

$results = mysql_query("SELECT  `name` , `address` , `city` , `phone` , `www` ,`id` FROM `bizlist` WHERE 1 AND `category` LIKE '%$query%'  ORDER BY name ASC LIMIT $page, $limit");
while ($data = mysql_fetch_array($results))

 

here is what I am trying to get working...this query works in phpmyadmin but not in the script (see error below)


$results = mysql_query("SELECT  `name` , `address` , `city` , `phone` , `www` ,`id` FROM `bizlist` WHERE `city` = 'Newark' AND `category` LIKE '%$query%'  ORDER BY name ASC LIMIT $page, $limit");
while ($data = mysql_fetch_array($results))

 

"mysql_fetch_array(): supplied argument is not a valid MySQL result resource"

 

any ideas ?

 

TIA

 


$results = mysql_query("SELECT  `name` , `address` , `city` , `phone` , `www` ,`id` FROM `bizlist` WHERE `city` = 'Newark' AND `category` LIKE '%$query%'  ORDER BY name ASC LIMIT $page, $limit") or die(mysql_error());
while ($data = mysql_fetch_array($results))

 

Add that and see what the error is in the sql.

the problem was it should have been $numresults and not $results

 

sorry I missed this and did not post the reference

 

but I am confused about the mesg database...I do have a db named "mesg" BUT it is NOT the datbase that the script connects to...this is really confusing...???

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.