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

Hi Forum,

At the tiem of running my sql string Its flagging an error with mysql_fetch_array(): supplied argument is not a valid

I dont’ know why its happening as I am running the same thing at other pages.

Please see the code below and let me know Where I mistook…


$keyname = mysql_real_escape_string($_GET['title']);
					$cityname = mysql_real_escape_string($_GET['id']);
					$areaname = mysql_real_escape_string($_GET['area']);
					
								   
             $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 like '$keyname%' and c.city = '$cityname' and b.biz_addy3 like '%$areaname%' order by b.biz_plan LIMIT 8"; 
						//echo $sql_c;
					  	$result_c=mysql_query($sql_c);
					  	$tot_record=mysql_num_rows($result_c);
					  
					  	$keynext = rawurlencode($keyname);
					    $record_per_page=10;
						$scroll=4;
						$zz= $keynext;
						$xz= "";
						$page1=new page1(); 
						
								
						$page1->set_page_data($_SERVER['PHP_SELF'],$tot_record,$zz,$xz,$record_per_page,$scroll,true,true,true);
						$result_c = mysql_query($page1->get_limit_query($sql_c));
						// For paging purpose 
						if($_GET['page']=="" || !isset($_GET['page']) || $_GET['page']==0)
							$sno=1;
						else
							$sno = ($record_per_page*$_GET['page'])+1;
					  
					  $sno_22 = 0;
					  if($tot_record > 0)
					  {
					  while($row_c=mysql_fetch_array($result_c))
					  {
					    $sno_22++;
						if($sno_22%3==1)
						{
					  ?>


Thanks for your help…in advance.!!!

Change


$result_c = mysql_query($page1->get_limit_query($sql_c));

into


$result_c = mysql_query($page1->get_limit_query($sql_c)) or die('sql error: ' . sql_error() . ' in query: ' . $page1->get_limit_query($sql_c));

And see what error message appears.

Thanks,

Now its flagging up with this error:

Fatal error: Call to undefined function sql_error() in

sorry, mysql_error() :smiley:

Ok, no probs, :slight_smile:

Here’s wt I got now:

sql error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘LIMIT 0,10’ at line 1 in query: 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 like ‘Dairy Equipments Dealers%’ and c.city = ‘Meerut’ and b.biz_addy3 like ‘%%’ order by b.biz_plan LIMIT 8 LIMIT 0,10

This query is working perfectly in mysql…

LIMIT 8 LIMIT 0,10
Two limits?

Ohh!..that’s the problem…now I got it…but I used it for 1 time only…why it was taking it twice…??? do u know that…???

BTW…Thanks so much for your help…Good Day!!!

You put the first LIMIT in $sql_c.
And my guess is that $page1->get_limit_query($sql_c) returns the query with a limit added to it. So that makes two limits.