Bug #52023 [Bgs]: mysqli prepared statements not working with PHP-GTK
[email protected] ("james dot bradley at simunix dot com") Tue, 8 Jun 2010 17:54:05 +0200 (CEST)
| Newsgroups | php.gtk.dev |
|---|---|
| Message-ID | <[email protected]> |
Edit report at http://bugs.php.net/bug.php?id=52023&edit=1 ID: 52023 User updated by: james dot bradley at simunix dot com Reported by: james dot bradley at simunix dot com Summary: mysqli prepared statements not working with PHP-GTK Status: Bogus Type: Bug Package: PHP-GTK related Operating System: Windows Vista PHP Version: Irrelevant New Comment: Apologies. It seems I am actually getting a result set, but when I try to use $name in: $iter = $buffer->get_end_iter(); $buffer->insert($iter, "$name\n" ); I get the following warning: HP Warning: GtkTextBuffer::insert() expects argument 2 to be string without null bytes, string given. Is this actually a bug with GtkTextBuffer::insert() rather than what I originally suggested? Sorry again! Previous Comments: ------------------------------------------------------------------------ [2010-06-08 17:15:29] [email protected] 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. ------------------------------------------------------------------------ [2010-06-08 14:59:59] 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. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=52023&edit=1