Shanna Posted April 9, 2012 Share Posted April 9, 2012 Hi, I am running MAMP on my Mac with PHP 5.2.17 and MySQL 5.5.22 dB. I am using the PHP with MySQL Essential Training course to learn PHP and My SQl. Part of one of the steps in Ch. 12 has you execute the query below but when I do I get the following error msg. I have looked and tried various things but cannot get his query to work. Please help !!! Thanks in advance, Shanna Error Msg: Database query failed. You have an error in your SQL syntax; check the maual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 1' at line 1. SQL: function get_subject_by_id($subject_id) { global $connection; $query = "SELECT * "; $query .= "FROM subjects "; $query .= "WHERE id=" . $subject_id ." "; $query .= "LIMIT 1"; $result_set = mysql_query($query, $connection); confirm_query($result_set); // REMEMBER: // if no rows are returned, fetch_array will return false if ($subject = mysql_fetch_array($result_set)) { return $subject; } else { return NULL; Quote Link to comment Share on other sites More sharing options...
Jessica Posted April 9, 2012 Share Posted April 9, 2012 echo the query. My guess is $subject_id is empty. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.