What is the error code for this SQL insert?
PHP code written in DW
<title>Untitled Document</title>
mysql_connect (' localhost ', ' root ', ' 778692 ');
mysql_query ("Set names GBK");
mysql_select_db (' Test ');
INSERT into ' test '. ' Votes ' (
' ID ',
' Sport ',
' Ballot '
)
VALUES (
' 4 ', ' Table tennis ', ' 0 '
)
?>
Why always error:
Parse error:syntax error, unexpected ' into ' (t_string) in C:\xampp\htdocs\toupiaopiao\result.php on line 15
------Solution--------------------
Dude, this code is wrong. Insert INTO is an SQL statement, how can you write it directly?
$sql = "INSERT INTO ... ";
mysql_query ($SQL, $conn); Conn is a linked object $conn =mysql_connect (' localhost ', ' root ', ' 778692 ');
SQL statement correctness you can directly first in the database to judge
------Solution--------------------
$sql =<<< SQL
INSERT into ' test '. ' Votes ' (
' ID ',
' Sport ',
' Ballot '
)
VALUES (
' 4 ', ' Table tennis ', ' 0 '
)
SQL;
mysql_query ($sql);
------Solution--------------------
PHP Code