php.net |  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
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: james dot bradley at simunix dot com
New email:
PHP Version: OS:

 

 [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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-08 17:15 UTC] auroraeosrose@php.net
-Status: Open +Status: Bogus
 [2010-06-08 17:15 UTC] auroraeosrose@php.net
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 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: Sat Dec 21 11:01:30 2024 UTC