I'm getting these errors:
Warning: mysqli_query(): MySQL server has gone away in (local db)
Warning: mysqli_query(): Error reading result set's header in (local db)
I am establishing a connection at first:
$connection = new mysqli($server, $user, $pass, $db) or die("unable");
Then this:
$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 looks like this:
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;
}
Error occurs at the second sql->execute. My guess is that it's because I'm using the connection for several requests but my knowledge of PHP does not allow me to figure out a solution.
Thank you!