mysqli连接总是失败的php7

时间:2017-09-15 14:29:13

标签: php mysql mysqli

我正在使用mysql_connect&它没有问题。更新到php7,因为它很快但无法连接到数据库。

这是我的代码。

function sql_connect($host, $user, $password, $db, $creat_db = 0)

{
    $dbi=mysqli_connect($host, $user, $password,$db);

        if (!$dbi)

    die("cannot connect to mysql server");

        return $dbi;


}


 $conn=sql_connect($db_info['host'], $db_info['user'], $db_info['pass'], $db_info['dbname']);

sql查询功能是

function sql_query($query)
{

   global $dbtype,$conn,$config;

    if (!$res = mysqli_query($conn,$query)) {

        echo"SQL query error!<br><b>Error infomation:</b><hr>[SQL]<br>".htmlspecialchars($query)."<br><br>[Error]<br><font color=red>".mysqli_error($conn)."</font>";exit();
    }
    return $res;

}

这里是简单的查询

  $res = sql_query("select * from `table1`");

但我总是得到这个错误SQL查询错误select * from table1  我没有收到任何错误。无论我在写的失败的查询中写的是什么。我的错误显示已打开,我添加了ini_set&amp; E_All也

总是输出

output is 

SQL query error!
Error infomation:
[SQL]
select * from `table1`

[Error]

任何帮助都会很棒

0 个答案:

没有答案
相关问题