im trying to retrieve data from my table only for some reason I receive a syntax error...
Can anybody see where i may be going wrong?
$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
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