mikwit Posted August 11, 2009 Share Posted August 11, 2009 This script originally worked, but now is returning nothing for me. I could always not use the count on the mysql side and use the mysql count results command, but that's not as efficient (I assume) and I'm really trying to build my site to scale well. the php code involved is $number=$_GET['a']; $sql = 'SELECT COUNT(*) AS CNT FROM comments WHERE replyto='.$number; $comnum = mysql_query($sql) or die('query broke:<br />'); echo $comnum['CNT']; This is returning nothing even though there are rows where replyto=$number... I'm almost positive it used to work, but I must have messed up something... Thanks so much, I would've given up on computers a long time ago if it wasn't for you guy's help. Link to comment https://forums.phpfreaks.com/topic/169711-solved-mysql-count-not-returning-anything/ Share on other sites More sharing options...
Maknis Posted August 11, 2009 Share Posted August 11, 2009 do a print_r($comnum); whats it say This script originally worked, but now is returning nothing for me. I could always not use the count on the mysql side and use the mysql count results command, but that's not as efficient (I assume) and I'm really trying to build my site to scale well. the php code involved is $number=$_GET['a']; $sql = 'SELECT COUNT(*) AS CNT FROM comments WHERE replyto='.$number; $comnum = mysql_query($sql) or die('query broke:<br />'); echo $comnum['CNT']; This is returning nothing even though there are rows where replyto=$number... I'm almost positive it used to work, but I must have messed up something... Thanks so much, I would've given up on computers a long time ago if it wasn't for you guy's help. Link to comment https://forums.phpfreaks.com/topic/169711-solved-mysql-count-not-returning-anything/#findComment-895343 Share on other sites More sharing options...
abazoskib Posted August 11, 2009 Share Posted August 11, 2009 you need to do this: $number=$_GET['a']; $sql = 'SELECT COUNT(*) AS CNT FROM comments WHERE replyto='.$number; $comnum = mysql_query($sql) or die('query broke:<br />'); $row=mysql_fetch_assoc($comnum); echo $row['CNT']; Link to comment https://forums.phpfreaks.com/topic/169711-solved-mysql-count-not-returning-anything/#findComment-895347 Share on other sites More sharing options...
mikwit Posted August 11, 2009 Author Share Posted August 11, 2009 you need to do this: That did the trick. Thanks a lot Link to comment https://forums.phpfreaks.com/topic/169711-solved-mysql-count-not-returning-anything/#findComment-895350 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.