Wednesday, 15 April 2015

php - You have an error in your SQL syntax (mySQL) -


I have questions like that before, and I have seen those topics and still do not think my syntax Find the error in - so I posted it myself.

  There is an error in your SQL syntax; To use the nearby INSERT_INTO users (UID, email, pass_hash, permissions, join-date) VALUES ('wright.ma' on line 1), check the manual related to your MySQL server version for the correct syntax   

My code is down, but everything else works up to SQL, which is valid for me.

  $ email = $ _POST ['email']; $ Pass = $ _POST ['pass']; $ Pass2 = $ _POST ['pass2']; $ UID = $ _POST ['UID']; $ Join_date = Date ("Y-M-DH: I: S"); If ($ _POST ['permissions']) {$ permission = $ _POST ['permissions']; } And {$ permission = 0; } If (! $ Email) {header ('HTTP / 1.1 500 internal server error'); Header ('content-type: application / jsan'); Exit ("Security Module Error - Email Address Not Provided"); } If (! $ Uid) {header ('HTTP / 1.1 500 internal server error'); Header ('content-type: application / jsan'); Exit ("Security Module Error - User ID Not Provided"); } If (! $ Pass =! $ Pass2 || ($ pass! = $ Pass2)) {header ('HTTP / 1.1 500 internal server error'); Header ('content-type: application / jsan'); Exit ("Security module error - password not provided or does not match"); } $ Pass_hash = crypt ($ pass, '$ 1 $$ hash $ 1'); $ Conn = @ mysql_connect ("localhost", "root", "root"); If (! $ Conn) {Header ('HTTP / 1.1 500 Internal Server Error'); Header ('content-type: application / jsan'); Exit ("Database Error - Unable to Connect"); } $ Db = @ mysql_select_db ("start", $ conn); If (! $ Db) {Header ('HTTP / 1.1 500 Internal Server Error'); Header ('content-type: application / jsan'); Exit ("Database Error - Unable to Access Database"); } $ Result = @ mysql_query ("$ uid", '$ email', '$ pass_hash', '$ permissions', $ join_date) "INSERT_INTO user (UID, email, pass_hash, permissions, when joining)" ); If (! $ Result) {header ('HTTP / 1.1 500 internal server error'); Header ('content-type: application / jsan'); Exit ("Database Error - Unable to create record (" .mysql_error ($ conn). ")"); } $ Row = mysql_fetch_array ($ result); If (! $ Line) {header ('HTTP / 1.1 500 internal server error'); Header ('content-type: application / jsan'); Exit ("Security module error - unable to authenticate record creation"); } And {$ _SESSION ['UID'] = $ line ['UID']; $ _SESSION ['Permissions'] = $ line ['Permission']; $ _SESSION ['email'] = $ line ['email']; }   

Second set of eyes ready to help will be greatly appreciated!

You have an underscore partitioning INSERT and INTO syntax should be "INSERT IN .... "

You should use PDO or mysqli, because mysql_ * functions have been deprecated.

No comments:

Post a Comment