What is the code for inserting SQL statements?

Source: Internet
Author: User
Tags parse error
What error codes does the code for inserting SQL statements have? PHP code written in DW & lt ;! DOCTYPEhtmlPUBLIC & quot;-W3CDTDXHTML1.0TransitionalEN & quot; www. w3.orgTRxhtml1DTDxhtml1-transitional. dtd & quot; & gt; & lt; what error code does this insert SQL?
PHP code written in DW





Untitled Document





Mysql_connect ('localhost', 'root', '123 ');
Mysql_query ("set names gbk ");
Mysql_select_db ('test ');
Insert into 'test'. 'votes '(

'Id ',
'Sport ',
'Ballot'
)
VALUES (
'4', 'table tennis ', '0'
)
?>




Why is an error always reported:
Parse error: syntax error, unexpected 'into' (T_STRING) in C: \ xampp \ htdocs \ toupiaopiao \ result. php on line 15




------ Solution --------------------
This code is incorrect, buddy. insert into is an SQL statement. how can I write it like this directly?
$ SQL = "insert ...";
Mysql_query ($ SQL, $ conn); // conn is the linked object $ conn = mysql_connect ('localhost', 'root', '123 ');

SQL statement correctness can be determined directly in the database
------ Solution --------------------
$ SQL = <SQL

Insert into 'test'. 'votes '(

'Id ',
'Sport ',
'Ballot'
)
VALUES (
'4', 'table tennis ', '0'
)
SQL;

Mysql_query ($ SQL );
------ Solution --------------------
PHP code
  

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.