w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Failed to run query: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds

The problem is a syntax problem in your query. The error is pretty clear at pointing it out, but here you go:

You've got (as @andrewsi points out) a couple of stray commas:

 $query = " 
        INSERT INTO users ( 
            username, 
            password, 
            salt, 
            email,
            name,
            gender,
            dateofbirth,
            nric,
            address,
            postalcode,
            mobilenumber,
            profession, <== This comma is extra.  Remove it.
        ) VALUES ( 
            :username, 
            :password, 
            :salt, 
            :email, 
            :name,
            :gender,
            :dateofbirth,
            :nric,
            :address,
            :postalcode,
            :mobilenumber,
            :profession, <== This comma is also extra.  Remove.
        ) 
    "; 

So that your query looks like this:

 $query = " 
        INSERT INTO users ( 
            username, 
            password, 
            salt, 
            email,
            name,
            gender,
            dateofbirth,
            nric,
            address,
            postalcode,
            mobilenumber,
            profession
        ) VALUES ( 
            :username, 
            :password, 
            :salt, 
            :email, 
            :name,
            :gender,
            :dateofbirth,
            :nric,
            :address,
            :postalcode,
            :mobilenumber,
            :profession
        ) 
    "; 




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.