php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37260 mysqli does NOT insert data
Submitted: 2006-05-01 14:58 UTC Modified: 2006-05-04 04:33 UTC
From: lana0 at zahav dot net dot il Assigned:
Status: Not a bug Package: MySQLi related
PHP Version: 5.1.2 OS: XP SP2 Home edition
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: lana0 at zahav dot net dot il
New email:
PHP Version: OS:

 

 [2006-05-01 14:58 UTC] lana0 at zahav dot net dot il
Description:
------------
extension php_mysqli.dll does not work properly in new release.

5.04 - it works
5.12 and 5.20SnapShort - it fails;

Reproduce code:
---------------
<?php
  //grant create,insert,select,delete on test.* to 'testuser'@'localhost';
  $db=mysqli_connect('localhost','testuser','','test');
  echo "Php version: ".phpversion()."\n";
  echo "Mysqli client version: ".mysqli_get_client_info()."\n";
  echo "Mysqli server version: ".mysqli_get_server_info($db)."\n";
  $Query='CREATE TABLE IF NOT EXISTS test.test (binData blob)';
  $res=mysqli_query($db,$Query);
  if ($res===TRUE){
    $Query='insert into test.test  set binData=?';
    $binData="\0";          //BYTE ZERO! 
    $binData="123x\000567"; //TRY
    $binData="12345";
    $stmt =mysqli_prepare($db,$Query);
    if (!$stmt){
      echo "Fail on prepare!";
      exit;
    }
    $res=mysqli_stmt_bind_param($stmt,'b',$binData);
    $res=mysqli_stmt_execute($stmt);
    if ($res){
      $Query="select length(binData) as n from test.test";
      $res=mysqli_query($db,$Query);
      if ($res){
        $row=mysqli_fetch_assoc($res);
        if ($row){
          mysqli_free_result($res);
          echo "input strlen=".strlen($binData)."\n";
          echo "stored strlen={$row['n']}"."\n";
          mysqli_query($db,'delete from test.test');
        }
      }
    }
  }
  exit;
?>


Expected result:
----------------
ver 5.0.4 works: (see strlen value)

R:\PhpMySQL>php blobcutzero.php
Php version: 5.0.4
Mysqli client version: 4.1.7
Mysqli server version: 5.0.16-nt
input strlen=5
stored strlen=5

Actual result:
--------------
new release fails: (see strlen value)

R:\PhpMySQL>php blobcutzero.php
Php version: 5.1.2
Mysqli client version: 4.1.7
Mysqli server version: 5.0.16-nt
input strlen=5
stored strlen=0

R:\PhpMySQL>php blobcutzero.php
Php version: 5.2.0-dev
Mysqli client version: 4.1.7
Mysqli server version: 5.0.16-nt
input strlen=5
stored strlen=0



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-01 15:36 UTC] lana0 at zahav dot net dot il
correct summary: mysqli does NOT insert data
 [2006-05-02 05:15 UTC] georg@php.net
Please try with a php_mysqli.dll (and libmysql.dll) linked against actual 5.0.20 sources from http://dev.mysql.com/downloads/connector/php/
 [2006-05-02 07:26 UTC] lana0 at zahav dot net dot il
I'm sorry, but upgrade mysqli from mysql site does not help.
Here are the updated results: 
1. mysqli client version changed.
2. the stored (fetched) length is incorrect.

R:\PhpMySQL>php blobcutzero.php
Php version: 5.1.2
Mysqli client version: 5.0.20
Mysqli server version: 5.0.16-nt
input strlen=5
stored strlen=0

R:\PhpMySQL>php blobcutzero.php
Php version: 5.2.0-dev
Mysqli client version: 5.0.20
Mysqli server version: 5.0.16-nt
input strlen=5
stored strlen=0
 [2006-05-04 04:33 UTC] georg@php.net
http://www.php.net/mysqli_stmt_bind_param

b: corresponding variable is a blob and will be send in packets

You don't use mysqli_stmt_send_long_data in your example code, so as expected the value of blob column is NULL.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 02:01:28 2024 UTC