从php v5.5迁移到php v5.3时代码不起作用

问题描述 投票:0回答:1

我正在使用以下功能从数据库读取数据。在我本地的php v5.5中,它运行良好。但是,当我将此代码上传到运行php v5.3的服务器时,它不起作用。

  function sql_select_many($sql, $db_connection) {
    $mysql_query = mysql_query($sql, $db_connection);
    if ($mysql_query){
        $quantity = mysql_num_rows($mysql_query);
        $return_result = array();
        if($quantity>0){
            $rows = array();
            while ($row = mysql_fetch_assoc($mysql_query)) {
                $rows[] = $row;
            }
            $return_result = array("success"=> true,'count' => $quantity, 'rows'=> $rows);
            mysql_free_result($mysql_query);
        }
        else{
            $return_result = array("success"=> true,'count' => $quantity);
        }
    }
    else{
        $mysql_error = mysql_error($db_connection);
        $error_description = "Failed to execute the following SQL statement: $sql. mysql_error(): $mysql_error";

        $return_result = array("success"=> false);
    }        
    return $return_result ;
}

我在这里使用上述功能-

$post_categories = sql_select_many("SELECT * FROM `post_categories` where is_active=1", $connection)["rows"];

有人可以帮助我确定与php v5.3不兼容的声明吗?>

我正在使用以下功能从数据库读取数据。在我本地的php v5.5中,它运行良好。但是,当我将此代码上传到运行php v5.3的服务器时,它无法正常工作。函数...

php-5.3 php-5.5
1个回答
0
投票

PHP 5.5.x中的大多数改进对现有代码没有影响。有几个incompatibilities

© www.soinside.com 2019 - 2024. All rights reserved.