Jump to content

[SOLVED] MYSQL num_row error


darkfreaks

Recommended Posts

ii get error: mysql_num_rows not valid on line so n so:

 

<?php 

$getCatStores = mysql_query("SELECT DISTINCT a.ownerid, u.store_name FROM probid_users u, probid_auctions a WHERE 

	".$subcatquery."

	a.listin!='auction' AND a.active='1' AND a.closed='0' AND a.deleted!='1' AND a.ownerid=u.id AND 

	u.active='1' AND u.store_active='1' AND u.aboutpage_type='2'");



	$isCatStores = mysql_num_rows($getCatStores);



	if ($isSubcats>0 || $isCatStores>0) {?>

Link to comment
https://forums.phpfreaks.com/topic/68634-solved-mysql-num_row-error/
Share on other sites

There is a problem with your query then, try catching the error:

 

<?php

$getCatStores = mysql_query("SELECT DISTINCT a.ownerid, u.store_name FROM probid_users u, probid_auctions a WHERE ".$subcatquery." a.listin!='auction' AND a.active='1' AND a.closed='0' AND a.deleted!='1' AND a.ownerid=u.id AND u.active='1' AND u.store_active='1' AND u.aboutpage_type='2'")or die(mysql_error());

?>

now i get

 

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 ') OR a.addlcategory IN ()) AND a.listin!='auction' AND a.active='1' AND a.close' at line 2

 

 

<?php

$subcatquery="a.category IN (".$all_subcats.") OR a.addlcategory IN (".$all_subcats.") AND ";

$getCatStores = mysql_query("SELECT DISTINCT a.ownerid, u.store_name FROM probid_users u, probid_auctions a WHERE ".$subcatquery." a.listin!='auction' AND a.active='1' AND a.closed='0' AND a.deleted!='1' AND a.ownerid=u.id AND u.active='1' AND u.store_active='1' AND u.aboutpage_type='2'")or die(mysql_error());

?>

 

 

 

 

i told you to echo your query for us to see it as a whole

 

but your query should look like this

 

SELECT DISTINCT a.ownerid, u.store_name FROM probid_users u, probid_auctions a 
	WHERE ".$subcatquery."     <--- should look like  where a.category IN ('1','2',etc) OR a.addlcategory IN ('test','test',etc) AND
       a.listin!='auction'
    AND a.active='1' 
	AND a.closed='0' 
	AND a.deleted!='1' 
	AND a.ownerid=u.id 
	AND  u.active='1' 
	AND u.store_active='1' 
	AND u.aboutpage_type='2'");

<?php

if ($catname!="") {

while (list($cat_array_id, $cat_array_details)=each($cat_array)) {

	list($cat_array_name, $userid) = $cat_array_details;

	$strResult = strpos($cat_array_name,$catname);

	if (trim($strResult)=="0") $cat_id[$catcnt++] = $cat_array_id;
?>

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.