|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52023 mysqli prepared statements not working with PHP-GTK
Submitted: 2010-06-08 14:59 UTC Modified: 2010-06-08 18:04 UTC
From: james dot bradley at simunix dot com Assigned:
Status: Not a bug Package: PHP-GTK related
PHP Version: Irrelevant OS: Windows Vista
Private report: No CVE-ID: None
 [2010-06-08 14:59 UTC] james dot bradley at simunix dot com
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);
     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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-08 17:15 UTC]
-Status: Open +Status: Bogus
 [2010-06-08 17:15 UTC]
Cannot reproduce:

Mysql 5.1 on windows 7
user testuser with rights to the testschema

PHP-GTK 2.0.1 from, PHP 5.2.13 NTS from 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

$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);
     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 17:54 UTC] james dot bradley at simunix dot com
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!
 [2010-06-08 18:04 UTC] james dot bradley at simunix dot com
Following my previous comment, $name is always 65536 characters worth of null bytes... Very strange!
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jul 22 16:01:29 2024 UTC