How to fix Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given ?

How to fix Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given ?

I'm making a private messaging system.
But I got the error message just like this again an again.

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\post\includes\pm_send.php on line 12

pm_send.php code is here

<?php

session_start();
require_once "connect.php";

$sql = "SELECT id, email FROM users WHERE showing='1'";
$result = mysql_query($sql);

$options = "";
$email = $_SESSION['email'];

while ($row=mysql_fetch_array($result)){
$USERid = $row['id'];
$USERname = $row['email'];
$option.="<OPTION VALUE=\"$USERid\">".$USERname."</OPTION>";
}
?>

How to fix it?

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

This issue is not related to this forum....you may find a proper forum for MySQL or PHP to get the answer...

But the issue looks like to be related to the value of "$result" returned from "mysql_query", this function may return a bool value (FALSE) when the query failed (example: no permission), instead of a query data-set. You may refer to this link to get the answer:

http://stackoverflow.com/questions/2973202/mysql-fetch-array-expects-par...

Hope it helps.

Thanks,

Shenghong

Leave a Comment

Please sign in to add a comment. Not a member? Join today