Parse error: syntax error, unexpected '$sql' (T_VARIABLE), expecting catch (T_CATCH)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jthemans
    New Member
    • Dec 2012
    • 2

    Parse error: syntax error, unexpected '$sql' (T_VARIABLE), expecting catch (T_CATCH)

    Hi guys I need some help with this code, can't figure out why it isn't working.

    Code:
    			try {
    				$db = new                   
                            PDO('mysql:host=localhost;dbname=boekenlijst','root','');
    			}
    
    		
    			$sql = 'SELECT auteur FROM boekenlijst';
    and the error I am getting is:
    Parse error: syntax error, unexpected '$sql' (T_VARIABLE), expecting catch (T_CATCH)

    Thanks in advance.
    Last edited by acoder; Dec 8 '12, 02:01 PM. Reason: Added [code] tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    You're missing the catch part of try/catch. See the PHP documentation or any simple tutorial.

    Comment

    Working...