Jump to content

Recommended Posts

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 ?

Link to comment
https://forums.phpfreaks.com/topic/250601-select-query-problem/
Share on other sites

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.