php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71476 Binding insert_id into prepared statement fails
Submitted: 2016-01-28 10:08 UTC Modified: 2017-05-21 04:22 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: j dot nord at ntlworld dot com Assigned:
Status: No Feedback Package: MySQLi related
PHP Version: 5.5.31 OS: ubuntu4.14
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
29 + 11 = ?
Subscribe to this entry?

 
 [2016-01-28 10:08 UTC] j dot nord at ntlworld dot com
Description:
------------
Using binding insert id into mysql prepared statement fails where a variable with the same value works perfectly.

Test script:
---------------
http://pastebin.com/umgSYhrz

Expected result:
----------------
Code should echo:
Able to commit

Actual result:
--------------
Code echoes:
Error executing query: Column 'Barcode' cannot be null

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-05-10 10:18 UTC] fjanisze@php.net
-Status: Open +Status: Feedback
 [2017-05-10 10:18 UTC] fjanisze@php.net
I'm not able to reproduce your problem with the latest builds. I've been using a slightly modified script:

.
$mysqli = new mysqli('localhost', 'root', '', 'test');

$mysqli->autocommit(false);
$stmt = $mysqli->prepare("INSERT INTO tab (id,name,age) VALUES(?,?,?)");
$plab = $mysqli->prepare("INSERT INTO labels (id) VALUES (?)");

$name = 'name';
$age = 10;

$stmt->bind_param("isi", $mysqli->insert_id, $name ,$age);
$stmt->execute();


$plab->bind_param("i", $db->insert_id);
$plab->execute();

if( $plab->error != '') {
    print 'error: '.$plab->error.PHP_EOL;
}
.

Can you verify again if on your environment this problem persist with recent releases? Thanks
 [2017-05-21 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 06:01:29 2024 UTC