Php programming connection to the database to read data tables

Source: Internet
Author: User
Php programming connection Database read data table problem my database has multiple data tables, only the table order can not read & nbsp; can only print 111 any other table can & nbsp; the error "QAQ & nbsp; & lt;?" is displayed ;? Php & nbsp; $ cornmysql_co php programming connection to the database to read data tables
My database has multiple data tables. only the table order cannot be read, and only 111 is printed.
Any other table can print 222
I don't know what's wrong with QAQ
   
 $ Corn = mysql_connect ('localhost', 'root ','');
Mysql_query ('set names utf8', $ corn );
If (! $ Corn)
Die ('could not connect: '. mysql_error ());
$ Db_selected = mysql_select_db ("daydream", $ corn );
If (! $ Db_selected)
Die ('Can \'t use foo: '. mysql_error ());

$ Query = mysql_query ("select * from order ");
If (! $ Query) echo 111;
Else echo 222; // these three rows are used to test whether the data table is read.
$ Row = mysql_fetch_array ($ query );

Echo"



CartNo: $ row [cartNo]
Customer No.: $ row [cusNo]
Product No.: $ row [proNo]
Purchase Time: $ row [cartDate]
Purchase Amount: $ row [cartSum]
Shipping Address: $ row [cartAddress]






";

Echo"

";
?>

------ Solution --------------------
$ Query = mysql_query ("select * from order ");
Order is the word
Change
$ Query = mysql_query ("select * from 'order '");
You can.

In fact, table names are generally not better than orders, but can be done using orders.
------ Solution --------------------
$query=mysql_query("select * from `order` ");

------ Solution --------------------
I know that the table name cannot use keywords.
However, if you have a keyword, you must use.

------ Solution --------------------
Only the table order cannot be read. only 111 rows can be printed.
Any other table can print 222. In fact, you already know the problem from your description, that is, the order table problem. what is the problem? like the keyword order, so change the table name or 'order'
------ Solution --------------------
Mysql reserved word http://www.cnblogs.com/lawdong/archive/2010/08/08/2357903.html
Do not escape any reserved words when they are used as other words: enclose them''
The following reserved words can be used as exceptions:
ACTION
BIT
DATE
ENUM
NO
TEXT
TIME
TIMESTAMP

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.