Hi guys, I am new here and also new to PHP and I'm working my way through some online tutorials. I have a small problem with an error which is holding up my progress and I would like some help.
I have a content.php file and a functions.php file which is included in which I have defined the following function:
function get_subject_by_id($subject_id) {
global $connection;
$query = "SELECT * FROM subjects WHERE id=".$subject_id . " LIMIT 1";
$result_set = mysql_query($query, $connection);
confirm_query($result_set);
if ($subject = mysql_fetch_array($result_set)) {
return $subject;
} else {
return NULL;
}
}
However, when I call the function thus in my content.php page :
$sel_subject = get_subject_by_id($sel_subj);
I get the following error:
DatabaSe query failed: 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 'LIMIT 1' at line 1
Now, I know the error is being generated by the confirm_query function I have, and I know that if I comment out the above function call I don't get the error...so I believe I must have messed up in the SQL syntax (as per the error report). However, I've checked it all over and I can't see the problem. I've even copy pasted the text from the exercise file so I know it's correct. Any ideas?
I am using an up to date version of XAMP and the video was put together in 2007. Could it be a change of syntax? I've tried removing the LIMIT 1 call but I still get an error.
Thanks in advance.