An SQL exception occurs on the iframe page in php.

Source: Internet
Author: User
An SQL error occurs on the iframe page in php when you create a shopping cart website. I am at home. iframe is a shopping cart on the right side of the php page. shopping_cart_form.php has always done well. I am at home. several textinput or something are added to each item in php. an SQL error occurs on the iframe page in shopping_cart_form.php.
Make a shopping cart website.
I have a shopping cart in iframe on the right side of the home. php page, shopping_cart_form.php
Everything was fine. I added a few text inputs to each item in home. php and added several SQL statements to shopping_cart_form.php.
However, if I add it to the shopping cart at one point, the iframe will display:
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 ''at line 1

I saw it in shopping_cart_form.php and couldn't find the SQL error.
Later, I changed shopping_cart_form.php to the previous normal code, and there was an error. it was good before!

How many inputs have been modified in home. php, which can affect the iframe?
PHP code
  // I have added a few items. // This is good. check the database and show that the data has been written in. $ Query = "insert into cart (username, dish_id, dish_qty, total_price, dest_id, shop_id) VALUES ('$ username',' $ dish_id ',' $ dish_qty ', '$ dish_total_price', '$ dest_id', '$ shop_id') "; // are there two errors below? There are so many SQL statements on this page. $ Query = "SELECT * from dish where dish_id = '$ dish_global_id'"; $ query = "insert into cart (username, dish_id, dish_qty, total_price, dest_id, shop_id) VALUES ('$ username',' $ dish_global_id ',' $ dish_global_qty ',' $ dish_global_total ',' $ dest_id ','')";


------ Solution --------------------
$ Query = "insert into cart (username, dish_id, dish_qty, total_price, dest_id, shop_id) VALUES ('$ username',' $ dish_global_id ',' $ dish_global_qty ', '$ dish_global_total', '$ dest_id ','')";

The last field of shop_id is ''. Is there a problem?
------ Solution --------------------
Really good.
What is it? What is it now?
You did not explain it!

Of course, you may find your problem when preparing to answer my questions.

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.