Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

bind-address mysql multiple, sanibleone xxxx, ftp://192.168.100.100/, www.xxxcon, which comes first ob_start or session, wwwxxx/58/2010, xxxxdup, xxxxdup, mailx informatii, should producers of software-based services, such as atms, be held liable for economic injuries suffered when their systems fail?

Links

XODOX
Impressum

#1: MYSQLi fetch corrupting bound variables

Posted on 2011-08-25 13:04:27 by Stuart Milne

--_000_CA7BEC35258Fstuartmtaopixcom_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi there

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

First of all here is some example code.

<?php

$pID =3D 0;
$recordID =3D 0;

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

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 =3D 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 $r=
ecordID 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 mYSQ=
L 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=20privile=
ged. It is intended solely for the addressee. Access to this email by anyo=
ne else is unauthorised. If you are not the intended recipient, any disclo=
sure, copying, distribution or any action taken or omitted to be taken in =
reliance on it, is prohibited and may be unlawful. All information provide=
d, including but not limited to, quotations, system specifications and sug=
gestions 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
____________________________________________________________ ____________
--_000_CA7BEC35258Fstuartmtaopixcom_--

Report this message

#2: Re: MYSQLi fetch corrupting bound variables

Posted on 2011-08-25 15:07:11 by Jim Giner

First glance: your 'if' needs '= =' not '='



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Report this message

#3: Re: Re: MYSQLi fetch corrupting bound variables

Posted on 2011-08-25 16:34:51 by Richard Quadling

On 25 August 2011 14:07, Jim Giner <jim.giner@albanyhandball.com> wrote:
> First glance: àyour 'if' needs '=3D =3D' ànot '=3D'

No.

Fully ...

if (False !== ($stmt =3D $dbObj->prepare(...))) {
...
}

In PHP, assignments evaluate to the value assigned.

If the value assigned can be evaluated as TRUE then the above test will pas=
s.




--=20
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Report this message

#4: Re: MYSQLi fetch corrupting bound variables

Posted on 2011-08-29 08:03:31 by Olivier Bietzer

Hello,

Shouldn't you "execute" the query first, and then "bind_result" ??

In the php doc
(http://jp2.php.net/manual/fr/mysqli-stmt.bind-result.php) the example
is done this way...

Hope this helps,

Olivier

Le 25/08/2011 13:04, Stuart Milne a écrit :
> 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
> ____________________________________________________________ ____________

--
---------------
Olivier Bietzer


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Report this message

#5: Learning bound variables ??

Posted on 2011-08-29 12:45:36 by Gavin Chalkley

--------------080406080406040203090108
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Afternoon all.

I am learning the base php at the moment and have come across scripting
that has the following examples:

"|header("Location: ".$this->referrer);"

Could someone point me in a direction to learn about this osrt of thing?

Or could some explain?

Best regards,

Gavin||
|

--------------080406080406040203090108--

Report this message

#6: Re: Learning bound variables ??

Posted on 2011-08-29 13:03:42 by Gavin Chalkley

Dian,

I appreciate what it does and understand the redirect.

What I am more refering to is the manner to which it is written

On 29/08/2011 12:02, dian.armstrong@gmail.com wrote:
> It's redirect script on php. Cmiiw
> ------Original Message------
> From: Gavin Chalkley
> To: php-db@lists.php.net
> Subject: [PHP-DB] Learning bound variables ??
> Sent: Aug 29, 2011 5:45 PM
>
> Afternoon all.
>
> I am learning the base php at the moment and have come across scripting
> that has the following examples:
>
> "|header("Location: ".$this->referrer);"
>
> Could someone point me in a direction to learn about this osrt of thing?
>
> Or could some explain?
>
> Best regards,
>
> Gavin||
> |
>
>
>
> Powered by Telkomsel BlackBerry®

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Report this message

#7: Re: Learning bound variables ??

Posted on 2011-08-29 15:53:29 by Amit Tandon

--20cf303639637b927804aba539dd
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Dear Gevin

I believe, u wish to understand about $this->...

Actually this is object oriented way of writing the variable. Here "this" i=
s
a key word and refers to the "this" instance of the object.

In simpler words if 2 different sessions are calling this line, then each
will pass on the value of "reffer" variable it has stored.

In non object syntax it would be written as
header("Location: ". $referrer)
============
regds
amit

"The difference between fiction and reality? Fiction has to make sense."


On Mon, Aug 29, 2011 at 4:33 PM, Gavin Chalkley <gavin.chalkley@gmail.com>w=
rote:

> Dian,
>
> I appreciate what it does and understand the redirect.
>
> What I am more refering to is the manner to which it is written
>
> On 29/08/2011 12:02, dian.armstrong@gmail.com wrote:
>
>> It's redirect script on php. Cmiiw
>>
>> ------Original Message------
>> From: Gavin Chalkley
>> To: php-db@lists.php.net
>> Subject: [PHP-DB] Learning bound variables ??
>> Sent: Aug 29, 2011 5:45 PM
>>
>> Afternoon all.
>>
>> I am learning the base php at the moment and have come across scripting
>> that has the following examples:
>>
>> "|header("Location: ".$this->referrer);"
>>
>> Could someone point me in a direction to learn about this osrt of thing?
>>
>> Or could some explain?
>>
>> Best regards,
>>
>> Gavin||
>> |
>>
>>
>>
>> Powered by Telkomsel BlackBerryî
>>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--20cf303639637b927804aba539dd--

Report this message

#8: Re: Learning bound variables ??

Posted on 2011-08-29 15:55:31 by Gavin Chalkley

--------------020303010609030300000601
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

Amit,

Many thanks for the explaination.

Is there a good book, or site to look at to learn this Object oriented
variable way of working?

Is it a cleaner way to work? Or does it over complicate things?

On 29/08/2011 14:53, Amit Tandon wrote:
> Dear Gevin
>
> I believe, u wish to understand about $this->...
>
> Actually this is object oriented way of writing the variable. Here
> "this" is a key word and refers to the "this" instance of the object.
>
> In simpler words if 2 different sessions are calling this line, then
> each will pass on the value of "reffer" variable it has stored.
>
> In non object syntax it would be written as
> header("Location: ". $referrer)
> ============
> regds
> amit
>
> "The difference between fiction and reality? Fiction has to make sense."
>
>
> On Mon, Aug 29, 2011 at 4:33 PM, Gavin Chalkley
> <gavin.chalkley@gmail.com <mailto:gavin.chalkley@gmail.com>> wrote:
>
> Dian,
>
> I appreciate what it does and understand the redirect.
>
> What I am more refering to is the manner to which it is written
>
> On 29/08/2011 12:02, dian.armstrong@gmail.com
> <mailto:dian.armstrong@gmail.com> wrote:
>
> It's redirect script on php. Cmiiw
>
> ------Original Message------
> From: Gavin Chalkley
> To: php-db@lists.php.net <mailto:php-db@lists.php.net>
> Subject: [PHP-DB] Learning bound variables ??
> Sent: Aug 29, 2011 5:45 PM
>
> Afternoon all.
>
> I am learning the base php at the moment and have come across
> scripting
> that has the following examples:
>
> "|header("Location: ".$this->referrer);"
>
> Could someone point me in a direction to learn about this osrt
> of thing?
>
> Or could some explain?
>
> Best regards,
>
> Gavin||
> |
>
>
>
> Powered by Telkomsel BlackBerryî
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--------------020303010609030300000601--

Report this message