Stromgren Posted January 19, 2012 Share Posted January 19, 2012 Hello I have a problem with a query i just created. When i run it, it returns this error: #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 '"INSERT INTO user (username, password, join_date, virksomhed, email, vej, postnu' at line 1 "INSERT INTO user (username, password, join_date, virksomhed, email, vej, postnummer, by, telefon) VALUES ('$username', SHA('$password1'), NOW(), '$virksomhed', '$email', '$vej', '$postnummer', '$by', '$telefon')" Can anyone please help me? Thanks in advance Link to comment Share on other sites More sharing options...
justsomeguy Posted January 19, 2012 Share Posted January 19, 2012 The double quote should not be part of the SQL query. SQL also does not understand PHP variables. Link to comment Share on other sites More sharing options...
Stromgren Posted January 19, 2012 Author Share Posted January 19, 2012 Thanks for the reply.. The double quotes and variables is showing because i copied from the PHP variable containing the query. It looks like this: $query = "INSERT INTO user (username, password, join_date, virksomhed, email, vej, postnummer, by, telefon) VALUES ('$username', SHA('$password1'), NOW(), '$virksomhed', '$email', '$vej', '$postnummer', '$by', '$telefon')"; This still won't work for me. Link to comment Share on other sites More sharing options...
Stromgren Posted January 19, 2012 Author Share Posted January 19, 2012 I found the error: A column in the database can't be named 'by' because its also a SQL function.."by" means "town" in Danish, so i guess I'm not the first one with this problem in Denmark Link to comment Share on other sites More sharing options...
justsomeguy Posted January 19, 2012 Share Posted January 19, 2012 The original error message showed the double quote as part of the query, maybe you pasted that into phpMyAdmin or something and copied too much. The error message showed this as the query: '"INSERT INTO user (username, password, join_date, virksomhed, email, vej, postnu' If you remove the single quotes surrounding that, you're left with this: "INSERT INTO user (username, password, join_date, virksomhed, email, vej, postnu So it was seeing the double quote as part of the SQL. If it was flagging "by" as the problem it would have started the query with that, e.g.: #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 'by, telefon) VALUES (...' at line 1 The first thing that it shows in the query in the error is usually the part that it had the problem with. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.