Php mysqli_query():MySQL服务器已离开

Php mysqli_query():MySQL服务器已离开,php,Php,我发现以下错误: Warning: mysqli_query(): MySQL server has gone away in (local db) Warning: mysqli_query(): Error reading result set's header in (local db) 我首先要建立一种联系: $connection = new mysqli($server, $user, $pass, $db) or die("unable"); 那么这个, $sql = $co

我发现以下错误:

Warning: mysqli_query(): MySQL server has gone away in (local db)

Warning: mysqli_query(): Error reading result set's header in (local db)
我首先要建立一种联系:

$connection = new mysqli($server, $user, $pass, $db) or die("unable");
那么这个,

$sql = $connection->prepare("INSERT INTO comments (name,mail,homepage,comment,time) VALUES (?,?,?,?,?)");
$sql->bind_Param('sssss',$name,$mail,$homepage,$comment,$time);
$sql->execute();
if($sql){
  if(!addPics($connection, $image_content, $mime, $time)){
      //other code
  }
addPics如下所示:

function addPics($connection, $image_content, $mime, $time){

    $sql = $connection->prepare("INSERT INTO pictures (picture, mime, time)  VALUES (?,?,?)");
    $sql->bind_Param('sss',$image_content,$mime, $time);
    $sql->execute();
    if($sql){
        return true;
    } else {
        return false;
    }
第二次sql->execute时出错。我的猜测是,这是因为我对几个请求使用了连接,但我的PHP知识不允许我找到解决方案


谢谢大家!

来展示我的评论

如果某些列名(或所有列名)在SQL中具有特殊含义,例如
name
time

$sql = $connection->prepare("INSERT INTO comments (`name`,`mail`,`homepage`,`comment`,`time`) VALUES (?,?,?,?,?)");
$sql->bind_Param('sssss',$name,$mail,$homepage,$comment,$time);


/* assign a variable to the `execute` method and test that var */
$result = $sql->execute();
if( $result ){

    /* the statement is now finished with, close it */
    $sql->close();


    if(!addPics($connection, $image_content, $mime, $time)){
        //other code
    }

感谢progman将其标记为副本,但增加允许的最大数据包数并没有解决我的问题。也许你可以在学校礼堂班长之外的其他方面提供帮助?试着释放语句对象-ie
$sql->close()
-另外,将
$sql->execute()
的结果分配给一个变量,并测试它是否解决了我的问题,而不是$sqlthanker@RamRaider。不幸的是,它打开了一个新的。。