-3

Possible Duplicate:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result

I am fetching data from MySQL data base in PHP but it gives error like following:

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/content/i/h/u/ihus235/html/cs/emrapp/surveyList.php on line 97 []

Below is the query which I am using to select data:

 $query = mysql_query("SELECT * form survey_Profile where user_Id='".$user_id."' ");
Community
  • 1
  • 1
Shahzad CR7
  • 125
  • 1
  • 1
  • 6

3 Answers3

5

change

$query = mysql_query("SELECT * form survey_Profile where user_Id='".$user_id."' ");

to

$query = mysql_query("SELECT * from survey_Profile where user_Id='".$user_id."' ");
Yogesh Suthar
  • 30,424
  • 18
  • 72
  • 100
2

The cause of tthat error can be that mysql returns False. You can add an:

echo "SELECT * form survey_Profile where user_Id='".$user_id."' ";

To see what string is send to mysql, eventualy test it directly in phpmyadmin. Also, add this code to see the error from mysql:

if (mysql_errno()) {
    echo "<br />". mysql_errno(). " : ". mysql_error(). "<br />";
}
CoursesWeb
  • 4,179
  • 3
  • 21
  • 27
0

You are getting this error because user_id value doesn't exist into your table.

So before executing your resource into mysql_fetch_assoc(), check whether you got matching rows or not.

if(mysql_num_rows($query) > 0) {
//user mysql_fetch_assoc now
}

And also you have sql syntax error, in your query replace "form" to "from"

GBD
  • 15,847
  • 2
  • 46
  • 50