thaidomizil Posted November 7, 2011 Share Posted November 7, 2011 Hi, i'm trying to select some entries from my DB, i don't quite understand what's the problem here, i'm using this: //Customers Online $query = "SELECT COUNT(*) as Anzahl FROM customers WHERE status = 1"; $queryerg = mysql_query($query) OR die(mysql_error()); while($row = mysql_fetch_array($queryerg)){ $customers_online = $row[0]; } Which works fine, now i want to select by country and i'm doing this: //Customers DE $query = "SELECT COUNT(*) as Anzahl FROM customers WHERE country = 'de'"; $queryerg = mysql_query($query) OR die(mysql_error()); while($row = mysql_fetch_array($queryerg)){ $customers_de = $row[0]; } Which doesn't work? If i print / echo $customers_de i just get a blank value, not even 0 or anything just blank. Any help ? Quote Link to comment https://forums.phpfreaks.com/topic/250601-select-query-problem/ Share on other sites More sharing options...
harristweed Posted November 7, 2011 Share Posted November 7, 2011 http://www.tizag.com/mysqlTutorial/mysqlcount.php Quote Link to comment https://forums.phpfreaks.com/topic/250601-select-query-problem/#findComment-1285793 Share on other sites More sharing options...
thaidomizil Posted November 7, 2011 Author Share Posted November 7, 2011 Please don't post random links, read my question, answer on that, if you can't don't answer at all ? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/250601-select-query-problem/#findComment-1285795 Share on other sites More sharing options...
PFMaBiSmAd Posted November 7, 2011 Share Posted November 7, 2011 If your $customers_de variable exists in the same scope where you printed/echoed it, you will get a zero if there where no matching rows or a number if there are matching rows. What's your complete actual code with the print/echo in it that reproduces the problem, because I just tested the second code that you posted and it prints a zero if the query returned a zero value. Do you have php's error_reporting set to E_ALL and display_errors set to ON so that php would report and display all the errors it detects in your code? Quote Link to comment https://forums.phpfreaks.com/topic/250601-select-query-problem/#findComment-1285827 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.