[support] db_num_rows(db_query(...)) issue

Kobus Myburgh itbjdm at puknet.puk.ac.za
Wed Jan 18 16:37:26 UTC 2006


Hi,

I am making a custom block for my Afrikaans translation Drupal site (www.drupal.co.za) with the following SQL query:

<?php
  $result1 = db_num_rows(db_query("SELECT COUNT(`translation`) from {locales_target} WHERE `translation` != ''"));
  $result2 = db_num_rows(db_query("SELECT COUNT(`translation`) from {locales_target}"));
  print $result1 . " van " . $result2 . " stringe (" . $result1 / $result2 * 100 . "%)";
?>

The result is this:

1 van 1 stringe (100%)

This is incorrect, even though, if I add these queries directly to phpMyAdmin, I get the values 942 and 1292 respectively. Of course, I have to replace {locales_target} with `locales_target` in phpMyAdmin, but nevertheless, either I am doing really silly wrong or something is terribly wrong with my copy of Drupal.

Could someone please indicate where my problem lies? Perhaps fix these queries if they are broken?

Thanks in advance,

Kobus




More information about the support mailing list