InsignificantPuppet
InsignificantPuppet

Reputation: 53

SQL Inserting Syntax Error

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.

Upvotes: 0

Views: 79

Answers (1)

John Conde
John Conde

Reputation: 219924

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).

Upvotes: 10

Related Questions