I'm trying to take entries via a registration form using php. But I'm getting following error:
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'
Here is my code:
 if($_SERVER['REQUEST_METHOD']=='POST'){
$name   = trim($_POST['name']);
$contact= trim($_POST['contact']);
$email  = trim($_POST['email']);
if(!empty($name) && !empty($contact) && !empty($email)){
    try {
        $conn = new PDO("mysql::host='localhost';dbname=majorproject;",'root','');
        //for error reporting and throwing exceptions
        $conn->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
        $stmt = $conn->prepare("insert into #_customerdata(customername,customercontact,customeremail) values(:name,:contact,:email)"); 
        $stmt->bindParam(':name',$name,PDO::PARAM_STR);
        $stmt->bindParam(':contact',$contact,PDO::PARAM_INT);
        $stmt->bindParam(':email',$email,PDO::PARAM_STR);
        if($stmt->execute()){
            header('location: ../customersignup.php?status=success');
        }
        else{
            header('location: ../customersignup.php?status=failed');
        }
    } catch (PDOException $e) {
        echo 'CONNECTION NOT ESTABLISHED '.$e;
    }
}
}
I have checked my code but couldn't find any errors.. Any suggestions to solve this problem??
 
     
     
    