Moving from php5.2.17 to 5.3.3

197 views Asked by At

I am moving a server from Centos 5 php5.2.17 to Centos 6 php5.3.3 I am facing up a problem with a code I didn’t wrote. There’s no problem in the old server for around two years but in the new one, tests warn me: mysql_fetch_array() expects parameter 1 to be resource, boolean given in path_to_template/template.php on line 43

Searching recursively: template.php ->line 43:

while($value_comment = mysql_fetch_array($result_comments))

$result_comments = getComments($unique_id);

function getComments($unique_id)
{
    $query = "SELECT * FROM (...)";
    $result = mysql_query($query);

    return $result;
}

$link = mysql_connect($host,$username,$password);
$db = mysql_select_db($db,$link);`

$host “…”;
$username = “…”;
$password = “…”;
$db = “…”;`

To get an output error I changed $result: $result = mysql_query($query) or die(mysql_error());

No database selected

I don’t realize what has changed between both php versions

Found the solution mysql username was imported but without privileges on any database (automatic things...!)

1

There are 1 answers

2
Péter Simon On

maybe your old server php error reporting is switched off. You recive this error, when the mysql returns 0 records.

$result = mysql_query($query);
$numResults = mysql_num_rows($result);
if ($numResults > 0) {
    // mysql_fetch_array
}