title: 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 3
body: <p>I'm new in PHP and MySQL and I got a little problem with my project I'm working on.</p>
  
  <p>Whenever I try to get data</p>
  
  <pre><code>$sql = "
  SELECT s.id_study_group
       , s.id_schedule
       , m.name_major
       , s.class_
       , ts.name_subject
       , s.time
       , r.name_room
       , s.day
       , s.semester
    FROM tbl_schedule as s
       , tbl_major as m
       , tbl_room as r
       , tbl_subject as ts
   WHERE s.id_major = m.id_major 
     and s.id_subject = ts.id_subject 
     and s.id_room = r.id_room 
     and s.id_lecturer =".$this-&gt;session-&gt;userdata('id_lecturer');
  </code></pre>
  
  <p>but I get the following error message:</p>
  
  <p>Error Number: 1064</p>
  
  <blockquote>
    <p>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 3</p>
  </blockquote>
  
  <p>which makes me confused is:
  the first time I run this program the program works, then I do not change the code and I the run back this program I got error like this</p>