Re: Subject: Strange bahavior with mysql_fetch_array($result)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If $result is returning a resource ID, this is because you have also used $result in the mysql_connect call.

You have probably also turned off error_reporting in your script, as it should throw an error for the 'if (! mysql_fetch_array...' line. The correct check is 'if (mysql_num_rows()==0)' which will catch any no-results set even if your query is broken and not returningn any resiults.

What is the contents of your query - print it out into the page.
Now, put it into phpMyAdmin as a query - does it return any results ?

Hope that helps - Neil.

At 01:57 21/11/2003 +0000, you wrote:
Message-ID: <78440-220031152115426406@xxxxxxxxxxxxxx>
From: "Evan Panagiotopoulos" <epanagio@xxxxxxxxxxxxxx>
To: php-db@xxxxxxxxxxxxx
Date: Thu, 20 Nov 2003 20:54:26 -0500
MIME-Version: 1.0
Content-type: text/plain; charset=iso-8859-1
Subject: Strange bahavior with mysql_fetch_array($result)

I am searching a table and have the following php code with my
comments:

$result = mysql_query($query);
print "The result == $result";
// it returns The result == Resource id #2"
if (!mysql_fetch_array($result)) {
 ...
} else {
  while ($row = mysql_fetch_array($result)) {
      ...
   }
}
Neither the if nor the while get executed.
Can you make any suggestions? Obviously I'm new to this.

Evan

-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux