MySQL Forums
Forum List  »  PHP

Re: mysql_fetch_array
Posted by: Jay Pipes
Date: June 20, 2005 10:38AM

You need a bit better error checking. Always verify that a result is a resource identifier before passing to mysql_fetch_array(). The problem is more than likely you have not established a connection, and so mysql_query() is not executing anything, even if the SQL is correct.

Try:

$query='select * from url_types order by type asc';
if (! $result=mysql_query($query)) {
echo mysql_error();
}
else {
while($row=mysql_fetch_array($result)) {
echo '<option value="', $row[0], '">' , stripslashes($row[1]), '</option>';
}
}

to get a little better error reporting...

Jay Pipes
Community Relations Manager, North America, MySQL Inc.

Got Cluster? http://www.mysql.com/cluster
Personal: http://jpipes.com

Options: ReplyQuote


Subject
Written By
Posted
June 20, 2005 09:35AM
Re: mysql_fetch_array
June 20, 2005 10:38AM
June 20, 2005 11:51AM
June 20, 2005 09:10PM
June 21, 2005 08:18AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.