我正在尝试将代码从php 5.6修改为php7,因此我将mysqli替换为mysqli,但出现以下错误:
致命错误:函数名称必须是第12行上的字符串

这是我的代码:

<?php include("day_image/config.php");
$time=time();
$jour=date("z",$time);
$conn = @mysqli_connect($host, $user, $pass, $bdd);
$req="select image from chat_du_jour where jour=$jour";
$res = $conn->query($req);
if (@mysqli_num_rows($res)!=0)
{
$row=@mysqli_fetch_row($res);
}
$req_chemin="select chemin from chat_du_jour where jour=$jour";
$res_chemin = $conn($req_chemin);
if (mysqli_num_rows($res_chemin)!=0)
{
$row_chemin=mysqli_fetch_row($res_chemin);
}
?>


在此先感谢您的帮助。

最佳答案

这只是拼写错误吗? $conn是一个对象:

$conn = @mysqli_connect($host, $user, $pass, $bdd);


但是您在第12行(错误消息指向您的行)将其用作函数名称:

$res_chemin = $conn($req_chemin);


我怀疑应该更像是:

$res_chemin = $conn->query($req_chemin);

关于php - 致命错误:函数名称必须是字符串,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36155843/

10-14 06:16