|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15565 AND operation errors on datas from MySQL Table
Submitted: 2002-02-15 06:01 UTC Modified: 2002-04-30 00:00 UTC
From: daniel dot alazet at libertysurf dot fr Assigned:
Status: No Feedback Package: Math related
PHP Version: 4.1.1 OS: any
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: daniel dot alazet at libertysurf dot fr
New email:
PHP Version: OS:


 [2002-02-15 06:01 UTC] daniel dot alazet at libertysurf dot fr
Can I submit a strange problem PHP / MySQL ?
From a very simple table, 1 key ( BYTE ), 2 vars ( INTEGER )
I initialise two records whith some values.
I read the first var from first record and second var from second record.
I do the AND ( & ) functiun on the two vars and I get a wrong result.
I join my test script to my request.
Please send problem analysis to
Best regards.


<title>Functiun AND Check</title>

// Data Base Open.
    $dbcnx = mysql_connect("localhost");
    if (!$dbcnx)
    {  echo( "<P>No access to Data Base Server.</P>" );
    if (! @mysql_select_db("BaseTest") )
    {  echo( "<P>No access to Data Base.</P>" );
// Table Cr?ation.
    $sql = "CREATE TABLE TEST (
           ".     " Num TINYINT UNSIGNED not null AUTO_INCREMENT,
           ".     " V1 INT (10) UNSIGNED not null,
           ".     " V2 INT (10) UNSIGNED not null,
           ".     " PRIMARY KEY (Num),
           ".     " UNIQUE (Num))
           ".     " comment = 'Table de Test.';"; 
    $crt = mysql_query($sql);
// First record create.
    $x = 0Xffffffff;
            ".   " V1='$x';";
    $ce = mysql_query($sql);
// Second record create.
    $x = 0X0f0f0f0f; 
            ".   " V2='$x';";
    $ce = mysql_query($sql);
// Vars initialisation .
    $a = 0;
    $b = 0;
// First record Read.
    $rt = MYSQL_QUERY("SELECT V1 FROM TEST WHERE (Num = 1)") or die("Erreur No: ".mysql_error());
    $ct = mysql_fetch_array($rt);
    if ($ct)
    {   $a = $ct[V1];
    mysql_free_result ($rt);
// Second record read.
    $rt = MYSQL_QUERY("SELECT V2 FROM TEST WHERE (Num = 2)") or die("Erreur No: ".mysql_error());
    $ct = mysql_fetch_array($rt);
    if ($ct)
    {   $b = $ct[V2];
    mysql_free_result ($rt);
// AND functiun on results and display.    
    $x = $a & $b;
    echo ("Var A = ".DecBin($a)."<br>");
    echo ("Var B = ".DecBin($b)."<br>");   
    echo ("AND Result = ".DecBin($x)."<br>");
// Correct display for vars.
// Waiting AND Result = 1111000011110000111100001111
// I get   AND Result = 1100010101010011001
// Where the error is?.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-16 05:44 UTC]
Works fine for me. Does the following script work for you?

$a = 0xFFFFFFFF;
$b = 0x0F0F0F0F;
$x = $a & $b;
echo decbin($a)."\n".decbin($b)."\n".decbin($x)."\n";

What OS are you running?


 [2002-04-30 00:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Dec 08 07:01:27 2023 UTC