I’m running this:
$stmt = $pdo->query( $sql); // I substitute $sql1 and $sql2 to test
while** ($row = $stmt->fetch())
{
echo** $row[ ‘name’ ] . “\n” ;
}
It works fine if I set the $sql using this line: $sql1= “select * from counties where state_id = 1” ;
But if I concatenate the state_id value using this line: $sql2 = "SELECT * FROM counties where state_id = " . $mystate; it fails.
Both look exactly the same when output to the page using echo.
Here’s the output:
SQL1: select * from counties where state_id = 1
SQL2: select * from counties where state_id = 1
I’m stumped. Any thoughts?