I am getting this error : 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 '' at line 1
I have absolutely not a clue what that means or where I went wrong, but ANY help would be appreciated. I've checked my DB username, pass and db name and they are all correct.
I am getting the error when I type in $subject_set = mysql_query("SELECT * FROM pages WHERE subject_id = ${subject["id"]}", $connection);
if (!$subject_set) {
die("database query failed: " . mysql_error());
}
this is my code:
<?php require_once("includes/connection.php"); ?>
<?php require_once("includes/functions.php"); ?>
<?php include("includes/header.php"); ?>
<div id="sidebar">
<ul>
<?php
$subject_set = mysql_query("SELECT * FROM subjects", $connection);
if (!$subject_set) {
die("database query failed: " . mysql_error());
}
while ($subject = mysql_fetch_array($subject_set)) {
echo "<li>{$subject["menu_name"]}</li>";
}
$subject_set = mysql_query("SELECT * FROM pages WHERE subject_id = ${subject["id"]}", $connection);
if (!$subject_set) {
die("database query failed: " . mysql_error());
}
while ($subject = mysql_fetch_array($subject_set)) {
echo "<li>{$subject["menu_name"]}</li>";
}
?>
</ul>
</div>
<div id="content">
<h1 class="sidebar">Content Area</h1>
</div>
</body>
</html>
<?php
mysql_close($connection);
?>