I have a table with about 50k records. Each record is associated with an activation code and a tinyint(1) that is either a 1 or a 0 depending on if it has been activated or not.
I wrote this script to search activation codes:
$count = 1;
foreach ($array as $value) {
try{
$stmt = $db->prepare("SELECT * FROM customers WHERE code = '$value'");
$stmt->execute();
$row = $stmt->fetchAll();
foreach ($row as $row1) {
echo "$count,{$row1['code']},{$row1['activated']} <br />";
}
}catch(PDOException $e){
echo $e;
}
$count++;
}
It will print out results as such:
263,GCTDA598149901,1
264,GCTDA363633527,1
265,GCTDA474011458,1
266,GCTDA610122649,1
267,GCTDA973129612,1
268,GCTDA472831092,1
269,GCTDA567914117,1
270,GCTDA763417638,1
271,GCTDA833541425,1
272,GCTDA556328307,1
273,GCTDA441015640,1
274,GCTDA266326284,1
275,GCTDA495338154,1
276,GCTDA320542455,1
277,GCTDA429649757,1
278,GCTDA468213166,1
279,GCTDA264634579,1
280,GCTDA842325439,1
281,GCTDA331321327,1
282,GCTDA280321014,1
283,GCTDA904841155,1
284,GCTDA728739105,1
All of the tinyint's are returned as a 1 whether is it a 1 or a 0 in the database. I am truly at a loss right now on what is causing it. I hope someone can help.
";` result in `{$row1['activated']}` being `1` for every line. So unless there is additional code the OP did not provide, I would question the db values before trying to blame the php code – Sean Jan 15 '15 at 20:40