strcmp() not returning zero for match
Posted: Sun Mar 14, 2004 11:10 am
The following code works fine when the user leaves the entry blank (to view all records in the database), but not when he makes an entry (in $_POST['Last'] entry) to omit the first reports. By use of print() and print_r() I have verified that everything is functioning as expected and that at one point there is a match.
$Row['Numbr'] is a varchar and never contains escaped characters. The entry, for instance, of 2457 in the $_POST should match to a database field content of 2457, but that entry does occur and does not reset the $Flag variable to zero, and I simply am missing the reason why it does not.
Anyone see what I'm missing?

$Row['Numbr'] is a varchar and never contains escaped characters. The entry, for instance, of 2457 in the $_POST should match to a database field content of 2457, but that entry does occur and does not reset the $Flag variable to zero, and I simply am missing the reason why it does not.
Code: Select all
<?php
if (isset($_POST['Last'])) // user clicked okay button: put all reports into
{ // a session array to be used for printing sequence
$_SESSION['Rcnt'] = 0; // the count of number to be done
$_SESSION['Doing'] = 0; // the one currently doing
$Flag = strlen($_POST['Last']); // greater than zero if entry made
$Query = "SELECT id FROM Stores ORDER BY Score,Num";
$Oresult = mysql_query($Query, $Link); // get stores by owner, number
while ($Orow = mysql_fetch_array($Oresult)) // owner based on sorting variable in the stores
{
$Query = "SELECT id,Numbr FROM Reports WHERE Sid=" . $Orow['id'];
$Result = mysql_query($Query, $Link);
if ($Row = mysql_fetch_array($Result)) // there will only be one report per store
{ if (!$Flag)
{ $_SESSION['Rcnt']++; // bump the array counter
$_SESSION['Run'][] = $Row['id']; // add report to the array
}
elseif (!strcmp($_POST['Last'],$Row['Numbr'])) $Flag = 0;
}
}
}
?>