0

Possible Duplicate:
PHP Error: mysql_fetch_array() expects parameter 1 to be resource, boolean given

php file

<?php
   session_start();
   $uniqueid = $_SESSION['unique'];
   $result = mysql_query("SELECT * FROM users_info  WHERE email='$uniqueid'");
   $user_mini_info = mysql_fetch_array($result);
 ?>

When i execute my php file, I get this warning

Warning: mysql_fetch_array() expects parameter 1 to be resource,
boolean given in .\profile.php on line 5

I dont know what does it really mean? why Im getting this warning ? Could anyone explain me what this warning really mean and how do i get rid off it? I belive due to this warning I am unable to update my page contents that are retrived from data base. any help is greatly appreciated.Thanks

Community
  • 1
  • 1
niko
  • 9,027
  • 27
  • 77
  • 130
  • 1
    change the code to `$result = mysql_query(...) or die(mysql_error());` to see why the query is failing. – Marc B Jan 17 '12 at 20:39
  • Your code suffers from SQL injection. Drop everything and read up on it here - http://en.wikipedia.org/wiki/SQL_injection – Kenaniah Jan 17 '12 at 20:39
  • @Kenaniah: Maybe. A session variable is set by and stored on the server, the client can't modify that... As long as the variable isn't set to something the client directly inputted, he's fine. – animuson Jan 17 '12 at 20:42
  • Feel a bit cheeky, hypocritical for saying this but: Pass it an Sql resource. – CBusBus Jan 17 '12 at 20:42

2 Answers2

2

You're getting "false", meaning an error has occurred. Check the documentation on mysql_query.

Try running echo(mysql_error()); to see what the error is.

Cyclone
  • 17,724
  • 45
  • 120
  • 188
0

A solution is

session_start();
$user_mini_info = array();
$uniqueid = $_SESSION['unique'];
$result = mysql_query("SELECT * FROM users_info  WHERE email='$uniqueid'");
if(!empty($result )) {
    $user_mini_info = mysql_fetch_array($result);
}
prdatur
  • 1,012
  • 1
  • 14
  • 20