SQL Inserting Syntax Error

InsignificantPuppet

Hey Guys I'm getting a syntax error with my SQL on my PHP page.

Basically what my page does is that it simply inserts data from a form and inserts into the database.

This is my code and my error:

Problem with query.

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 2

$sql = "INSERT INTO user (username, password, gname, mname, surname, address, state, postcode, tel)
VALUES ( '$usernamestr', '$passwordstr','$firstnamestr', '$middlenamestr’, '$familynamestr', '$addressstr', '$statestr', '$postcodestr', '$phonestr');";
$rs = mysql_query($sql, $conn)
or die ('Problem with query' . mysql_error());

I thought this was the way to do it? which is absolutely weird.

John Conde

You have a funky quote:

VALUES ( '$usernamestr', '$passwordstr','$firstnamestr', '$middlenamestr’, '$familynamestr', 
                                                                       ^^^^
                                                                       HERE

It is a and needs to be a ' (as the syntax highlighter shows in my answer but not in your question).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Error in your SQL syntax while Inserting to table

syntax error: inserting LPAREN

SQL syntax inserting into table

to_sql "Incorrect syntax" error on inserting DataFrame to [schema].[table]

Syntax error in SQL when inserting data via nodejs

SQL syntax error when inserting date into database (framework: codeigniter)

Inserting data into database but getting an error of MySQLSyntaxErrorException: You have an error in your SQL syntax

TM1 : Error :Incorrect syntax Near '|' (inserting numeric value into sql query)

SQL OperationalError: near "%": syntax error when using inserting values into a table with "executemany"

Issue with Inserting JSON data into MySQL database using Python, error in your SQL syntax

MySQL the world database sql file has syntax error when inserting data

"Syntax error or access violation" when inserting dates using PDO and SQL Server

How to prevent "SQL syntax error" when inserting binary image data into MySQL blob field?

Syntax error when inserting into foreign key

Syntax error when inserting to MySQL table in PHP

Syntax Error when Inserting New Data Into Table

Syntax error in mysql when inserting an image into a database

having trouble inserting values into table with syntax error

java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; when inserting data into SQL database through JAVA

SQL syntax error , Incorrect Syntax?

SQL ERROR - Error sql syntax

Syntax error of AND in SQL Query

SQL Server - Syntax Error

Error in SQL Syntax

SQL syntax error

MySQLSyntaxErrorException: Error in SQL Syntax

Dreamweaver error in SQL syntax

Where is the sql syntax error?

sql lite syntax error