What is the code for inserting SQL?

Source: Internet
Author: User
Tags parse error
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
  
   
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.