I just started with PHP and I don't understand why this line won't work
$zoek = '2341 KG';
foreach ($pdo->query ("select * from blad1 where Postkode = $zoek" ) as $klant)
but this one does work perfect
foreach ($pdo->query ("select * from blad1 where Postkode = '2341 KG' " ) as $klant)
You should prepare that query.
$stmt = $pdo ->prepare("select * from blad1 where Postkode = ?" );
$stmt->execute(array($zoek));
$klant = $stmt->fetch();//no loop it's a single record!
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments