0

I am getting the error below and was wondering if anyone could help me in resolving the error.

PHP Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /var/www/html/2plan/include/class.user.php on line 261, referer: http://localhost/2plan/install.php?action=step3

Below is a portion of the code from the class.user.php file

/**
 * Get a user profile
 *
 * @param int $id User ID
 * @return array $profile Profile
 */

function getProfile($id)
{
    $id = (int) $id;

    $sel = mysql_query("SELECT * FROM ".$this->getTableName()." WHERE ID = $id");
    $profile = mysql_fetch_array($sel);' //This is line 261

Appreciate if anyone can point me into the right direction on what needs to be done to correct the error. Thanks in advance.

Darren
  • 12,924
  • 4
  • 37
  • 76
  • Your query fails then `$sel = false` and you cannot pass it to `mysql_fetch_array()`. – DrKey Mar 13 '17 at 23:53
  • why dont you `print_r("SELECT * FROM ".$this->getTableName()." WHERE ID = $id")` and tell us your output. Try running that directly on your database to see what errors you get. – CodeGodie Mar 13 '17 at 23:55
  • Thanks @DrKey for respnding. I am a newbie just started learning php and mysql and would appreciate how this can be resolved. Thanks – Robert Griffin Mar 13 '17 at 23:56

1 Answers1

0

Really, that code is outdated as you SHOULD NOT be using mysql, rather use mysqli or pdo Why shouldn't I use mysql_* functions in PHP?.

But if you must, do the following to see errors:

 if(!$sel) die("ERROR: " . mysql_error()); 
Community
  • 1
  • 1
CodeGodie
  • 11,914
  • 5
  • 35
  • 64
  • I am installing an open source software called '2-Plan'. This is the team version. There are a few errors that have popped up in the error logs and this is just one of them. I'll change the codes and post the outcome. – Robert Griffin Mar 14 '17 at 00:45
  • Cool yea let us know what you get. – CodeGodie Mar 14 '17 at 00:53