user3558177
user3558177

Reputation: 943

mysqli and prepared statements

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

Upvotes: 0

Views: 26

Answers (1)

Rakesh Sharma
Rakesh Sharma

Reputation: 13738

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(?)

Upvotes: 1

Related Questions