Hi There,
I have this error and i cannot sort it out…can somebody assist
error : SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax.
Here is my DB design:
[php]categories:
id catname
1 shoes
2 clothes
subcategories:
idsubcat subcatname
1 mocassins
2 shirts
categorysubs:
cat_id subcat_id
1 1
2 2
Here is my code
if (isset($_GET[‘subcategory_id’]) && is_numeric($_GET[‘subcategory_id’])) {
$subcat_id = $_GET[‘subcategory_id’];
} else{
$subcat_id = NULL;
}
if ($subcat_id) {
try {
include_once(’…/…/connection.php’);
$query = “SELECT cat_id FROM categorysubs WHERE subcat_id = :subcat_id”;
$s = $pdo->query($query);
$s->bindValue(’:subcat_id’, $subcat_id);
$s->execute();
$results = $stmt->fetch(PDO::FETCH_ASSOC);
print_r($results);
} catch (PDOException $e) {
$output .= “Unable to process query”.$e->getMessage();
}
}[/php]