0

I cannot see to find the problem in this php code:

if ($stmt = $mysqli->prepare("INSERT INTO Champions(Spell 1) VALUES(?)")) { $stmt->bind_param('s', $SP1); $stmt->execute(); $stmt->close(); } else { printf("Errormessage: %s\n", $mysqli->error); } } 

Just throws the error: 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 '1) VALUES (?)' at line 1

4
  • 1
    What is Spell 1 supposed to do in the query? That's a literal and a number, not a string or column name. Commented Nov 20, 2014 at 4:50
  • 1
    Try this $mysqli->prepare("INSERT INTO Champions('Spell 1') VALUES(?)") Commented Nov 20, 2014 at 4:51
  • 1
    If that's your field name, delimit it with backticks... Poor choice for a field name though... Commented Nov 20, 2014 at 4:52
  • Ya I really should just use an underscore then I guess, Thanks Commented Nov 20, 2014 at 4:53

1 Answer 1

1

CAUSE YOU HAVE SPACE IN FIELD NAME

Spell 1 

try with proper fieldname

INSERT INTO Champions(Spell 1) VALUES(?) ^ 

or use quoting(not tried)

INSERT INTO Champions(`Spell 1`) VALUES(?) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.