Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php+;请帮帮我_Php_Sql - Fatal编程技术网

php+;请帮帮我

php+;请帮帮我,php,sql,Php,Sql,此代码运行良好 $sql = "INSERT INTO EventTest (name,text,lat,lon,date,time,type,number,adress) VALUES ('$name','$text','$lat','$lon','$date','$time','$type','$number','$address')"; $sth = $con->prepare($sql); $sth->execute(); 我在上一个块之后添加了此代

此代码运行良好

    $sql = "INSERT INTO EventTest (name,text,lat,lon,date,time,type,number,adress) VALUES ('$name','$text','$lat','$lon','$date','$time','$type','$number','$address')";
    $sth = $con->prepare($sql);
    $sth->execute();
我在上一个块之后添加了此代码

    $sql1 = "SELECT id FROM EventTest ORDER BY id DESC LIMIT 1";
    $sth1 = $con->prepare($sql1);
    $sth1->execute();
    $sth1->bind_result($id)
    while($sth1->fetch()) {     
    $data['YES'] = $id;
    }
该表包含所有字段。 此代码不起作用


我无法从服务器接收错误。

我看到一个错误,因此我将打赌,并提供一个简短的答案

在此行末尾添加分号:

$sth1->bind_result($id);

错误消息是什么?不要通过变量插值生成SQL。使用绑定参数!在测试时,错误不会发送到客户端。您需要检查服务器上的PHP错误日志。一个简单的缺少分号的问题被作为SQL问题发布是荒谬的。你甚至不需要检查错误日志。任何像样的IDE都会显示此错误。