mysql_fetch_array() expects parameter 1 to be resource

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
User avatar
nehrav
Forum Commoner
Posts: 38
Joined: Sun Sep 20, 2009 6:55 am
Location: New Delhi
Contact:

mysql_fetch_array() expects parameter 1 to be resource

Post by nehrav »

Hi friends,

I am getting this error : 8O

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\test\edit.php on line 11

with this code

<?php
$con = mysql_connect("localhost","new","test");
$db = mysql_select_db("test",$con);


$select = mysql_query("select * from table");

echo "<table border='0' cellpadding='0'
cellspacing='0' width='500'>";

while($result = mysql_fetch_array($select))
{
$id = $result['id'];
$name = $result['name'];

$age = $result['age'];

$salary = $result['salary'];

echo "<tr><td>$name</td><td>$age</td><td>$salary</td
><td><A HREF='delete.php?name=$name'>DELETE</A></td><td><A
HREF='update.php'>UPDATE</A></td></tr>";

}
echo "</table>";


?>
robnet
Forum Commoner
Posts: 85
Joined: Mon Aug 10, 2009 8:32 am
Location: South East, UK

Re: mysql_fetch_array() expects parameter 1 to be resource

Post by robnet »

Hi Nehrav,
First, can you surround your code in [ php]code[ /php] tags (Without the space after '[')? it makes long extracts of code much easier to read by code highlighting, auto scrolling and numbering lines.

Second, it looks like the query isn't working. use mysql_error() to see the specific error, then paste it back here if you aren't sure where to go from there.
http://uk2.php.net/mysql_error

For example try this:

Code: Select all

$select = mysql_query("select * from table") or die(mysql_error());
Post Reply