PDOException SQLSTATE[42000]: Syntax error or access violation: 1064
<p>I'm trying to take entries via a registration form using php. But I'm getting following error:</p>

<p>exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 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 1' </p>

<p>Here is my code:</p>

<pre><code> if($_SERVER['REQUEST_METHOD']=='POST'){

$name   = trim($_POST['name']);
$contact= trim($_POST['contact']);
$email  = trim($_POST['email']);

if(!empty($name) &amp;&amp; !empty($contact) &amp;&amp; !empty($email)){

    try {
        $conn = new PDO("mysql::host='localhost';dbname=majorproject;",'root','');
        //for error reporting and throwing exceptions
        $conn-&gt;setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);



        $stmt = $conn-&gt;prepare("insert into #_customerdata(customername,customercontact,customeremail) values(:name,:contact,:email)"); 

        $stmt-&gt;bindParam(':name',$name,PDO::PARAM_STR);
        $stmt-&gt;bindParam(':contact',$contact,PDO::PARAM_INT);
        $stmt-&gt;bindParam(':email',$email,PDO::PARAM_STR);

        if($stmt-&gt;execute()){
            header('location: ../customersignup.php?status=success');
        }
        else{
            header('location: ../customersignup.php?status=failed');
        }


    } catch (PDOException $e) {
        echo 'CONNECTION NOT ESTABLISHED '.$e;

    }





}

}
</code></pre>

<p>I have checked my code but couldn't find any errors.. Any suggestions to solve this problem??</p>