Bug #75813 [NEW]: Can't catch mysqli_sql_exception if bind_param() has mismatch

From: Date: Sat, 13 Jan 2018 21:03:10 +0000
Subject: Bug #75813 [NEW]: Can't catch mysqli_sql_exception if bind_param() has mismatch
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213532@lists.php.net to get a copy of this message
From: dtm824 at gmail dot com Operating system: MacOS High Sierra PHP version: 7.1.13 Package: MySQLi related Bug Type: Bug Bug description:Can't catch mysqli_sql_exception if bind_param() has mismatch Description: ------------ Using mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT) converts all MySQLi errors to exceptions, except for if there is a mismatch in bind_result(). This occurs in both the bound variables and types. An error with the following message is shown: Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement Test script: --------------- $stmt = $mysqli->prepare("SELECT id, name, age FROM myTable WHERE name = ?"); $stmt->bind_param("si", $_POST['name'], $_POST['age']); $stmt->execute(); $arr = $stmt->get_result()->fetch_all(MYSQLI_ASSOC); if(!$arr) exit('No rows'); var_export($arr); $stmt->close(); Expected result: ---------------- I should be able to catch all MySQLi exceptions, but this specific error is not converted to an exception. -- Edit bug report at https://bugs.php.net/bug.php?id=75813&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75813&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75813&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75813&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=75813&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=75813&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=75813&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=75813&r=needscript Try newer version: https://bugs.php.net/fix.php?id=75813&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=75813&r=support Expected behavior: https://bugs.php.net/fix.php?id=75813&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=75813&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=75813&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=75813&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75813&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=75813&r=dst IIS Stability: https://bugs.php.net/fix.php?id=75813&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=75813&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=75813&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=75813&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=75813&r=mysqlcfg

« previous php.bugs (#213532) next »