0
<?php
// Working SELECT query.
$db = new SQLite3('casino.db');
// This works great and returns only name = bergpau !!!
$results = $db->query('SELECT * FROM employe WHERE username="bergpau"');
while ($row = $results->fetchArray())
print $row['nom'] . "<BR>";
// This DOES NOT WORK AT ALL, returns no values !!! HELP !!!
$astring = "bergpau";
$results = $db->query('SELECT * FROM employe WHERE username=$astring');
while ($row = $results->fetchArray())
print $row['nom'] . "<BR>";
?>
開放數據庫,確定 沒有返回值,因爲它不能驗證在WHERE子句無法插入WHERE語句在PHP查詢變量
您是否檢查錯誤?第二個SELECT看起來像會導致一個mysql錯誤 – Terminus
http://stackoverflow.com/questions/5605965/php-concatenate-or-directly-insert-variables-in-string這將是你感興趣的 – Terminus