Re: PHP and MySQL

by "Srinivasan Ramakrishnan" <srinivar(at)>

 Date:  Mon, 23 Oct 2000 01:11:46 +0530
 To:  <hwg-languages(at)>,
"Ben Ocean" <lists(at)>
 References:  thewebsons
  todo: View Thread, Original
Hi Ben,

I must warn you I don't use mySQL regularly, I'm more of an Oracle guy, and
I'm new to PHP. Well now that I've shirked all responsibilty for the
following, here goes:

mysql_query() returns a FALSE which is 0 in PHP when the SELECT fails. And
hence mysql_numrows() [on line 81] which is expecting a positive non-zero
result identifier fails, when it encounters the 0 (zero).

In all probability the SQL statement you executed on line 80 is not
returning any data or is wrong. Better add a result checking condition even
if this is not where the error is, it's a good practice.

Ofcourse, I could be more sure if I could look at more of the code. PHP can
sometimes like all languages spot a error and report the wrong line number!!

Sure you $seating is a valid variable name.


----- Original Message -----
From: Ben Ocean <lists(at)>
To: <hwg-languages(at)>
Sent: Sunday, October 22, 2000 10:47 PM
Subject: PHP and MySQL

> Hi;
> I'm taking a script I wrote that worked for one client and trying to tweak
> it for another client. These clients are built on the same server. I have
> run into this error message:
> Warning: 0 is not a MySQL result index in
> on line 81
> Here is the script circa line 81...
>          if ($colorz != 9 ) { // ADD THIS LATER && $seatingz !=9 && $typez
> != 9) {
>          echo "<center><font style=\"font: 800 25px futura\">Here's Your
> Spas!</font></center>";
>          echo "Click on any spa.";
> /* LINE 80 */         $result = mysql_query("SELECT id, seating,
> color_two, color_three, type, name, jets, jets_one, jets_two, jets_three,
> jets_four, jets_five, jets_six, jet_system, dimensions, capacity, dry,
> filled, light, control, heater, thermostat, jetPumps, circulationPump,
> filter, filtration, water_care, price FROM spas ORDER BY price DESC");
>          $total_rows = mysql_numrows($result); $counter = 0; $countertwo =
>          while($counter < $total_rows):
> do a bunch of stuff...
> Can someone please help me?
> Also, I'm wondering if there's a more elegant way to label variables than
>                  $seatingee = mysql_result($result,$counter,"seating");
> If I don't need *seating* any more, can I simply call the result
> instead of *$seatingee* ?
> TIA,
> BenO

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA