一段时间后php脚本连接错误

时间:2018-07-18 18:30:45

标签: php sql database

我正在读取一个csv文件并更新远程DB上的DB字段。我大约有1200行,在750行之后我收到了此消息

警告:mysqli_connect():(HY000 / 2002):连接尝试失败,因为一段时间后被连接方未正确响应,或者由于连接的主机未能响应而建立的连接失败。在第53行的C:\ xampp7 \ htdocs \ folder \ file_name.php中 连接失败:连接尝试失败是由于一段时间后被连接方未正确响应,或者是由于连接的主机未能响应而导致建立连接失败。

每次这个数字都不相同意味着有时候我可以更新750,有时可以更新800

    function unsubscribe($email_id, $created_at){
$servername1 = "name";
    $username1 = "name";
    $password1 = "pass";
    $dbname1 = "dbName";

    // Create connection
    $conn1 = mysqli_connect($servername1, $username1, $password1, $dbname1);
    // Check connection
    if (!$conn1) {
        die("Connection failed: " . mysqli_connect_error());
    }
    $timestamp = strtotime($created_at);
    $sql = "update email_list set unsubscribed = '" . $timestamp . "' where emailaddress = '" . $email_id . "'";
    echo "OnServer  Date = " . $created_at . " and Timestamp =  " . $timestamp . " and email = " . $email_id . "<br>";
    mysqli_query($conn1, $sql);
    mysqli_close($conn1);
}

0 个答案:

没有答案