From: [EMAIL PROTECTED]
Operating system: any
PHP version: 4.1.1
PHP Bug Type: MySQL related
Bug description: AND operation errors on datas from MySQL Table
Hello
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 [EMAIL PROTECTED]
Best regards.
<html>
<head>
<title>Functiun AND Check</title>
</head>
<?php
// Data Base Open.
$dbcnx = mysql_connect("localhost");
if (!$dbcnx)
{ echo( "<P>No access to Data Base Server.</P>" );
exit();
}
if (! @mysql_select_db("BaseTest") )
{ echo( "<P>No access to Data Base.</P>" );
exit();
}
// 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;
$sql = "INSERT INTO TEST SET
". " V1='$x';";
$ce = mysql_query($sql);
// Second record create.
$x = 0X0f0f0f0f;
$sql = "INSERT INTO TEST SET
". " 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?.
?>
</body>
</html>
--
Edit bug report at http://bugs.php.net/?id=15565&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=15565&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=15565&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=15565&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=15565&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=15565&r=support
Expected behavior: http://bugs.php.net/fix.php?id=15565&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=15565&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=15565&r=submittedtwice