Error message when running SQL statement, solving

Source: Internet
Author: User
Date_default_timezone_set ("Asia/shanghai");
$h =date ("h:i:s");
$j =date ("y-m-d");
$k =date ("y-m-d h:i:s");
Require_once ("dbtools.inc.php");//contains files, not provided here, is about database creation and execution of SQL statements, you can write your own
$link = Create_connection ();//Ibid.
mysql_query ("SET NAMES gb2312");
mysql_query ("SET NAMES UTF8");
$sql = "SELECT * FROM ABC";
$result = Execute_sql ("Data", $sql, $link);//This function is not provided in the include file and can be written by itself

if (mysql_num_rows ($result) <1) {
$query =mysql_query ("INSERT INTO ABC" ' Stock ticker ', ' Stock name ', ' Market Time ', ' latest price ', ' Last Close ', ' open now ', ' up and down ', ' low price ', ' high price ', '

Change ', ' turnover ', ' turnover ', ' Commission ', ' date ') VALUES (' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' $j ') ');
if ($query!=true) {echo "Exit". Mysql_errno (). Mysql_error ();}
echo "sucess";}
?>
After running, the following prompt runs 1064You with an error in your SQL syntax; Check the manual-corresponds to your MySQL server version for the right syntax-use-near ', ' volume ', ' turnover ', ' Commission ', ' date ') v Alues (",", ",", ",", ",", "," at line 1:


Reply to discussion (solution)

Change the full-width comma inside to half-width.

It's supposed to change.
$query =mysql_query ("INSERT INTO ABC" ' Stock ticker ', ' Stock name ', ' Market Time ', ' latest price ', ' Last Close ', ' open now ', ' up and down ', ' low price ', ' high price ', ' Change ', ' turnover ', ' turnover ', ' Commission ratio ', ' Date ') VALUES (' ', ' ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' $j ') ');

The question of commas? No, it should be okay to change it.
$query =mysql_query ("INSERT INTO ABC" ' Stock ticker ', ' Stock name ', ' Market Time ', ' latest price ', ' Last Close ', ' open now ', ' up and down ', ' low price ', ' high price ', ' Change ', ' turnover ', ' turnover ', ' Commission ratio ', ' Date ') VALUES (' ', ' ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' $j ') ');

Not how to move ah, which is different, I do not see, is not my field and the number of inserted data ah, or in Chinese as a field MySQL is not allowed??

Your code obviously has a newline character before the change.

If you do a field name in Chinese, be aware that the character set of the table is correct

Character set problem to say, is nothing more than "mysql_query (" set NAMES gb2312 ");
mysql_query ("SET NAMES UTF8"); " It's all been tried, no way. In addition, "Your code in the change before the obvious there is a line break", the declaration, the source is not. Again, the comma problem, just tried, Chinese comma, comma, comma, full-width comma is not used. The error is the same as "1064You has an error in your SQL syntax; Check the manual-corresponds to your MySQL server version for the right syntax-use-near ', ' volume ', ' turnover ', ' Commission ', ' date ') v Alues (', ', ', ', ', ', ', ', ', ', ' at line 1 ')

It's supposed to change.
$query =mysql_query ("INSERT INTO ABC" ' Stock ticker ', ' Stock name ', ' Market Time ', ' latest price ', ' Last Close ', ' open now ', ' up and down ', ' low price ', ' high price ', ' Change ', ' turnover ', ' turnover ', ' Commission ratio ', ' Date ') VALUES (' ', ' ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' $j ') ');


Brother said right, I tried, unexpectedly success, can be detailed to say why? Why can't I write it, you can change it, and I don't see how it's different. Thanks.


It's supposed to change.
$query =mysql_query ("INSERT INTO ABC" ' Stock ticker ', ' Stock name ', ' Market Time ', ' latest price ', ' Last Close ', ' open now ', ' up and down ', ' low price ', ' high price ', ' Change ', ' turnover ', ' turnover ', ' Commission ratio ', ' Date ') VALUES (' ', ' ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' $j ') ');


Brother said right, I tried, unexpectedly success, can be detailed to say why? Why can't I write it, you can change it, and I don't see how it's different. Thanks.



1. Because of the one you wrote, some commas use a comma in Chinese.
Change ', ' turnover ', ' turnover ', ' Commission ', ' date ') VALUES (' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' $j ') ');
2. $query =mysql_query ("INSERT INTO ABC" (' Stock ticker ', ' Stock name ', ' Market Time ', ' latest price ', ' Last Close ', ' open now ', ' ups and downs ', ' low price ', ' high price ', '

Change ', ' turnover ', ' turnover ', ' Commission ', ' date ') VALUES (' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' $j ') ');
Here you go, so no.



It's supposed to change.
$query =mysql_query ("INSERT INTO ABC" ' Stock ticker ', ' Stock name ', ' Market Time ', ' latest price ', ' Last Close ', ' open now ', ' up and down ', ' low price ', ' high price ', ' Change ', ' turnover ', ' turnover ', ' Commission ratio ', ' Date ') VALUES (' ', ' ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' $j ') ');


Brother said right, I tried, unexpectedly success, can be detailed to say why? Why can't I write it, you can change it, and I don't see how it's different. Thanks.



1. Because of the one you wrote, some commas use a comma in Chinese.
Change ', ' turnover ', ' turnover ', ' Commission ', ' date ') VALUES (' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' $j ') ');
2. $query =mysql_query ("INSERT INTO ABC" (' Stock ticker ', ' Stock name ', ' Market Time ', ' latest price ', ' Last Close ', ' open now ', ' ups and downs ', ' low price ', ' high price ', '

Change ', ' turnover ', ' turnover ', ' Commission ', ' date ') VALUES (' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' $j ') ');
Here you go, so no.


Thanks, it seems that the foundation is not strong enough, go down there must be a lot of practice.
  • 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.