Jump to content
Killersites Forums

Occasional Php Warning When Looping Multiple Mysqli Queries


Recommended Posts

My PHP script for mysqli queries works most of the time, but while running a loop that queries database many times, occasionally I'll get Warning:

PHP Warning:  mysqli_stmt::execute(): (HY000/2013): Lost connection to MySQL server during query in... blah blah blah

Can someone tell me if I need to modify the structure of my queries to make it work better?  Here's my example:

 

 

<?php

 

$host = "localhost";
$username = "blah_blah";
$password = "blah_blah";
$database = "blah_blah";

$mysqli = new mysqli($host, $username, $password, $database,0,'/var/lib/mysql/mysql.sock'); 
$mysqli->set_charset('utf8');

 

if ($stmt = $mysqli->prepare("SELECT column_A FROM table_X WHERE column_B=? AND column_C=? LIMIT 1")){
 $stmt->bind_param("si", $value_1, $value_2);
 $stmt->execute();
 $stmt->bind_result($column_A_value);
 $stmt->fetch();
 $stmt->close();
}

 

?>

Link to post
Share on other sites
  • 4 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...