darkfreaks Posted September 9, 2007 Share Posted September 9, 2007 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) {?> Quote Link to comment https://forums.phpfreaks.com/topic/68634-solved-mysql-num_row-error/ Share on other sites More sharing options...
pocobueno1388 Posted September 9, 2007 Share Posted September 9, 2007 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()); ?> Quote Link to comment https://forums.phpfreaks.com/topic/68634-solved-mysql-num_row-error/#findComment-344972 Share on other sites More sharing options...
darkfreaks Posted September 9, 2007 Author Share Posted September 9, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/68634-solved-mysql-num_row-error/#findComment-344978 Share on other sites More sharing options...
teng84 Posted September 9, 2007 Share Posted September 9, 2007 can you echo this one ".$subcatquery." and see the result i guess that missed the" and" Quote Link to comment https://forums.phpfreaks.com/topic/68634-solved-mysql-num_row-error/#findComment-344979 Share on other sites More sharing options...
darkfreaks Posted September 9, 2007 Author Share Posted September 9, 2007 <?php $subcatquery="(a.category IN (".$all_subcats.") OR a.addlcategory IN (".$all_subcats.")) AND ";?> Quote Link to comment https://forums.phpfreaks.com/topic/68634-solved-mysql-num_row-error/#findComment-344981 Share on other sites More sharing options...
teng84 Posted September 9, 2007 Share Posted September 9, 2007 should be a.category IN (".$all_subcats.") OR a.addlcategory IN (".$all_subcats.") AND " and be sure that the value of $all_subcats is correct and separated by comma Quote Link to comment https://forums.phpfreaks.com/topic/68634-solved-mysql-num_row-error/#findComment-344988 Share on other sites More sharing options...
darkfreaks Posted September 9, 2007 Author Share Posted September 9, 2007 example? im kina lost Quote Link to comment https://forums.phpfreaks.com/topic/68634-solved-mysql-num_row-error/#findComment-344994 Share on other sites More sharing options...
teng84 Posted September 9, 2007 Share Posted September 9, 2007 better to echo your query and ill try to fix it Quote Link to comment https://forums.phpfreaks.com/topic/68634-solved-mysql-num_row-error/#findComment-344997 Share on other sites More sharing options...
darkfreaks Posted September 9, 2007 Author Share Posted September 9, 2007 <?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()); ?> Quote Link to comment https://forums.phpfreaks.com/topic/68634-solved-mysql-num_row-error/#findComment-344998 Share on other sites More sharing options...
teng84 Posted September 9, 2007 Share Posted September 9, 2007 oops sorry i mean this echo $getCatStores ; Quote Link to comment https://forums.phpfreaks.com/topic/68634-solved-mysql-num_row-error/#findComment-344999 Share on other sites More sharing options...
darkfreaks Posted September 9, 2007 Author Share Posted September 9, 2007 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.closed' at line 2 Quote Link to comment https://forums.phpfreaks.com/topic/68634-solved-mysql-num_row-error/#findComment-345000 Share on other sites More sharing options...
teng84 Posted September 9, 2007 Share Posted September 9, 2007 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'"); Quote Link to comment https://forums.phpfreaks.com/topic/68634-solved-mysql-num_row-error/#findComment-345007 Share on other sites More sharing options...
darkfreaks Posted September 9, 2007 Author Share Posted September 9, 2007 <?php $all_subcats = implode (",",$cat_id); ///<------ errors $subcatquery="a.category IN (".$all_subcats.") OR a.addlcategory IN (".$all_subcats.") AND "; ?> Also pretty sure the implode issue is causing the SQL issue Quote Link to comment https://forums.phpfreaks.com/topic/68634-solved-mysql-num_row-error/#findComment-345010 Share on other sites More sharing options...
teng84 Posted September 9, 2007 Share Posted September 9, 2007 whoa !! print this $all_subcats and this print_r($cat_id); then show us the result we cant see whats on that array its hard to predict why you git that error unless we see the content of those variables Quote Link to comment https://forums.phpfreaks.com/topic/68634-solved-mysql-num_row-error/#findComment-345016 Share on other sites More sharing options...
darkfreaks Posted September 9, 2007 Author Share Posted September 9, 2007 <?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; ?> Quote Link to comment https://forums.phpfreaks.com/topic/68634-solved-mysql-num_row-error/#findComment-345021 Share on other sites More sharing options...
teng84 Posted September 9, 2007 Share Posted September 9, 2007 we cant sort this out every time you post an answer its like your giving me another prob look all im asking is to print_r($cat_id); and echo $all_subcats; and echo $getCatStores; and from there we can determine where to start Quote Link to comment https://forums.phpfreaks.com/topic/68634-solved-mysql-num_row-error/#findComment-345025 Share on other sites More sharing options...
darkfreaks Posted September 9, 2007 Author Share Posted September 9, 2007 nothing pops up when i echo it? just the stupid errors! Quote Link to comment https://forums.phpfreaks.com/topic/68634-solved-mysql-num_row-error/#findComment-345027 Share on other sites More sharing options...
pocobueno1388 Posted September 10, 2007 Share Posted September 10, 2007 You need to comment the line out that is creating the errors, that way it will get down to the part that your trying to execute. Quote Link to comment https://forums.phpfreaks.com/topic/68634-solved-mysql-num_row-error/#findComment-345028 Share on other sites More sharing options...
darkfreaks Posted September 10, 2007 Author Share Posted September 10, 2007 ok i commented out implode and the subcat now the echos show up on the bottom look: http://www.bidders.co.za/categories.php?category=1920s&parent=217 Quote Link to comment https://forums.phpfreaks.com/topic/68634-solved-mysql-num_row-error/#findComment-345030 Share on other sites More sharing options...
darkfreaks Posted September 10, 2007 Author Share Posted September 10, 2007 anyone? Quote Link to comment https://forums.phpfreaks.com/topic/68634-solved-mysql-num_row-error/#findComment-345039 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.