|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-11-27 14:13 UTC] georg@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 07:00:01 2025 UTC |
Description: ------------ Make a multiple queries that contains a buggy DML SQL command with mysqli_multi_query can cause MySQL connection closed: mysqli_ping returns false right after mysqli_multi_query() invocation. Apache 2.2.6 MySQL 5.0.67 Reproduce code: --------------- <?php ini_set('mysqli.reconnect', 'Off'); $mysqli = mysqli_init(); mysqli_real_connect($mysqli, "localhost", "root", "123456", "test"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } /* CREATE TABLE `test2` ( `id` int(11) DEFAULT NULL, `username` varchar(100) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; Buggy DML SQL command: INSERT INTO test2 VALUES (1008-, 'pcdinh5') */ $query = "INSERT INTO test2 VALUES (1007, 'pcdinh4');INSERT INTO test2 VALUES (1008-, 'pcdinh5');"; /* execute multi query */ mysqli_multi_query($mysqli, $query); if (false === mysqli_ping($mysqli)) { exit('Database connection is closed'); } ?> Expected result: ---------------- Nothing happens. If this script produces a message: Database connection is closed means there is a problem Actual result: -------------- This script produces a message: Database connection is closed