我试图从我的表中检索数据只是出于某种原因我收到一个语法错误......
任何人都可以看到我可能会出错的地方吗?
$cid = $_GET['id'];
$username = 'liam';
$password ='';
try {
$conn = new PDO('mysql:host=localhost;dbname=', $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$data = $conn->query('SELECT * FROM directory WHERE ID = :cid');
$data->bindValue(":cid", $cid);
foreach($data as $row) {
print_r($row). '<br />';
}
错误
ERROR: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':cid' at line 1