title: Uncaught PDOException: Syntax error or access violation: 1064 from improper spacing
body: <p>I am getting two different types of errors from a single line and it took me long to find out where the error was. This is an interesting behavior php shows while concatenating MySql query statements using bacticks for seperating strings.</p>
  
  <pre><code>$query='SELECT c.name as category_name, p.id, p.category_id, p.title, p.body, p.author, p.created_at
      FROM'.$this-&gt;table. ' p
      LEFT JOIN categories c ON p.category_id=c.id
      ORDER BY p.created_at DESC';
  </code></pre>
  
  <p>Notice: No space between FROM and backtick. The error follows is</p>
  
  <blockquote>
    <p><br /> <b>Fatal error</b>:  Uncaught PDOException: SQLSTATE[
            42000 ]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your
    MariaDB server version for the right syntax to use near 'p
            LEFT JOIN categories c ON p.category_id=c.id
            ORDER BY p.crea' at line 2 in C:\xampp\htdocs\php_REST_myblog\models\Post.php: 31 Stack trace:
        <br>#0 C:\xampp\htdocs\php_REST_myblog\models\Post.php(31): PDOStatement-&gt;execute()
        <br>#1 C:\xampp\htdocs\php_REST_myblog\api\posts\read.php(18): Post-&gt;read()
        <br>#2 {main }   thrown in <b>C:\xampp\htdocs\php_REST_myblog\models\Post.php</b> on line
        <b>31</b><br /></p>
  </blockquote>
  
  <p>The next variation is</p>
  
  <pre><code>  $query='SELECT c.name as category_name, p.id, p.category_id, p.title, p.body, p.author, p.created_at
      FROM '.$this-&gt;table. 'p
      LEFT JOIN categories c ON p.category_id=c.id
      ORDER BY p.created_at DESC';
  </code></pre>
  
  <p>Notice no space between backtick and p. DB name is myblog and table name is posts.The error follows is</p>
  
  <blockquote>
    <p><br /> <b>Fatal error</b>:  Uncaught PDOException: SQLSTATE[   42S02
    ]: Base table or view not found: 1146 Table 'myblog.postsp' doesn't
    exist in C:\xampp\htdocs\php_REST_myblog\models\Post.php: 31 Stack
    trace:
        <br>#0 C:\xampp\htdocs\php_REST_myblog\models\Post.php(31): PDOStatement-&gt;execute()
        <br>#1 C:\xampp\htdocs\php_REST_myblog\api\posts\read.php(18): Post-&gt;read()
        <br>#2 {main }   thrown in <b>C:\xampp\htdocs\php_REST_myblog\models\Post.php</b> on line
        <br><b>31</b><br /></p>
  </blockquote>
  
  <p>The correct code is below with two extra spaces.</p>
  
  <pre><code>$query='SELECT c.name as category_name, p.id, p.category_id, p.title, p.body, p.author, p.created_at
          FROM '.$this-&gt;table. ' p
          LEFT JOIN categories c ON p.category_id=c.id
          ORDER BY p.created_at DESC';
  </code></pre>
  
  <p>What is going wrong?</p>