Click here to Skip to main content
15,889,859 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /storage/ssd1/632/6410632/public_html/Admin/User.php on line 135

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /storage/ssd1/632/6410632/public_html/Admin/User.php on line 150


What I have tried:

<pre>// Specify the query to execute
$sql = "select * from User_Master";
// Execute query
$result = mysql_query($sql,$con);
// Loop through each records
while($row = mysql_fetch_array($result))
{
$Id=$row['UserId'];
$UserName=$row['UserName'];</pre>
Posted
Updated 25-Jul-18 4:58am

1 solution

This question is asked almost every day. Just look at the "Related questions" list - and that's just a small sample.

As always, the answer is that you need to read the documentation:
For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset, mysql_query() returns a resource on success, or FALSE on error.

Something has gone wrong with your query. You need to test whether the method returned FALSE before trying to read the results.

NB: The MySQL extension has been deprecated since 5.5, and was removed completely in 7.0; you need to use MySQLi or PDO instead.
PHP: Choosing an API - Manual[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900