MYSQLi fetch corrupting bound variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi there

Getting a weird issue with MySQLi fetch when using bound variables.

First of all here is some example code.

<?php

$pID = 0;
$recordID = 0;

if ($stmt = $dbObj->prepare('SELECT `id`, name FROM MYTABLE WHERE id = ?)
{

 if ($stmt->bind_param('i', $pID))
 {
 if ($stmt->bind_result($recordID, $name)
 {
 if ($stmt->execute())
    {
 $stmt->fetch();
 }
 }
 }

}

?>

Now I initialize the $recordID variable to 0;

The SELECT statement then does a SELECT where id = 0; In my table there is no record with the id of 0;

Also notice that in my bind_result i am binding the the result into the $recordID variable.

Now this is where it gets weird for me. On some versions of PHP and MYSQl the $recordID variable is still set to 0 but on other versions of PHP mYSQL the $recordID seems to be overwritten and set to NULL from the fetch.

Any ideas as to why these differences are occurring.

Regards
Stu
________________________________
E-MAIL DISCLAIMER
The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. All information provided, including but not limited to, quotations, system specifications and suggestions concerning hardware/software/services configurations are strictly subject to our standard terms and conditions of business, copies of which are available on request.

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux