|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-06-08 14:59 UTC] james dot bradley at simunix dot com
Description:
------------
Normal mysqli queries work fine with PHP-GTK but prepared statements never return any rows from a query. I have tested the same prepared statement code outside of PHP-GTK in a WAMP installation and there it runs fine, indicating it is more than likely a bug with mysqli prepared statements and PHP-GTK. Note that even "SELECT name from saved_data" with no conditions doesn't work as a prepared statement so the problem is not with bind_param.
Test script:
---------------
// runs fine in PHP-GTK and WAMP
if($result = $mysqli->query("SELECT name FROM saved_data WHERE data_id<10")) {
while ($row = $result->fetch_object()) echo $row->name;
}
// doesn't work in PHP-GTK (does work in WAMP)
$num = 10;
if($stmt = $mysqli->prepare("SELECT name FROM saved_data WHERE data_id<?")) {
$stmt->bind_param("i", $num);
$stmt->bind_result($name);
$stmt->execute();
while($stmt->fetch()) {
echo $name;
}
}
Expected result:
----------------
The same output should be generated from both of the above scripts.
Actual result:
--------------
The non-prepared statement outputs the expected rows, the prepared statement does not.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 08:00:02 2025 UTC |
Cannot reproduce: Mysql 5.1 on windows 7 user testuser with rights to the testschema PHP-GTK 2.0.1 from gtk.php.net, PHP 5.2.13 NTS from PHP.net downloaded and dropped over the 2.0.1 package to get the mysqli extension php-cli.ini edited, added extension=php_mysqli.dll php -m from the php-gtk2 directory includes mysqli Following code works perfectly <?php $mysqli = new mysqli('localhost', 'testuser', 'testuser', 'testschema'); if ($mysqli->connect_error) { die('Connect Error (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error); } $num = 3; $name = null; if($stmt = $mysqli->prepare("SELECT test FROM new_table WHERE idnew_table < ?")) { $stmt->bind_param('i', $num); $stmt->bind_result($name); $stmt->execute(); while($stmt->fetch()) { echo $name; } } else { echo $mysqli->error; } Check your php-gtk setup. Add some error handling to your code to see if that if loop is actually even being entered, and check for a prepare error.