I am trying to get data from the url but it flagging this error…

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/content/83/4759683/html/DID_index/srch/searchkey2.php on line 79

This is the link I am calling…

<a href="../srch/searchkey2.php?id=1&amp;title=<?=$row_category['category']?>

And on searchkey2.php…I am getting it something like this…

<?  $keyname = $_GET['title'];
$sql_c="select * from bcc join tblcity c on bcc.city_id = c.city_id join tblbusinessinfo b on bcc.business_id = b.biz_id join 			

tblcat t on bcc.category_id = t.category_id where t.category = $keyname and = ".$_GET['id'].""; 

>>>>>line 79		           $tot_record=mysql_num_rows($result_c);
						$page1=new page1(); 
						$result_c = mysql_query($page1->get_limit_query($sql_c));
						// For paging purpose 
						if($_GET['page']=="" || !isset($_GET['page']) || $_GET['page']==0)
							$sno = ($record_per_page*$_GET['page'])+1;
					  $sno_22 = 0;
					  if($tot_record > 0)

Its annoying very much…can you please help me, if there is any way to solve this…???


The reason the argument is not a valid result resource is that your query was bad, so mysql_query returned FALSE instead of a result set.

Always a good idea to write and test your queries before adding them to your PHP code. All literal strings in SQL queries have to be enclosed by single quotes.

SELECT * FROM table WHERE column = 'the title'


SELECT * FROM table WHERE column = the title

Thanks Dan,

So you mean to say…it should be…

where t.category = ‘$keyname’ and = “.$_GET[‘id’].”

Instead of…

where t.category = $keyname and = “.$_GET[‘id’].”

Thanks, Dan,

Its working now…Thanks a lot…

I don’t know what’s in your table. Print out the query instead of running it, then copy and paste that into your favorite mysql client to see what it returns yourself.

If there is no error then you are missing nothing except some data in the table that matches the conditions in where clause. So try to echo the query that the function $page1->get_limit_query($sql_c) returns and run this in phpmyadmin to see if there are records.

Thanks its fine now…I was missing something in my query…so silly…but thanks for your help…

Thanks Rajug,

You are right…Its fine now…thanks to you.

Wonder why no one mentioned injection here.

$keyname = mysql_real_escape_string($_GET[‘title’]);
same for id

Thanks Shrapnel,

I’ve heard about injection…but not implemented yet…Thanks for your helping answer…Much Appreciated…

How many things should one see and suggest the OP before reply for a problem. I normally concentrate on the problem what OP has asked for. But obviously it is good if someone can just analyze the whole code and mention possible suggestions. You are the man Shrapnel who can see everything and good eyes you have :wink: