How can I read data from the mysql interface in PHP?

Source: Internet
Author: User
Could you please help me see how this PHP mysql reading interface cannot read data ??? This is the CREATETABLEIFNOTEXISTS 'TM _ comment' ('playerid' textNOTNULL, 'message' textNOTNULL, 'color' textNOTNULL, 'fontsize' varchar (3) NO. could you please help me see how this PHP mysql reading interface cannot read data ???
This is for creating a database

Create table if not exists 'TM _ comment '(
'Playerid' text not null,
'Message' text not null,
'Color' text not null,
'Fontsize' varchar (3) not null,
'Mode' varchar (2) not null,
'Playtime' varchar (4) not null,
'Date' text NOT NULL
) ENGINE = InnoDB default charset = utf8;






This is the write interface


$ Vid = $ _ POST ['playerid'];
$ Message = $ _ POST ['message'];
$ Color = $ _ POST ['color'];
$ Fontsize = $ _ POST ['fontsize'];
$ Mode = $ _ POST ['mode'];
$ Playtime = $ _ POST ['playtime'];
$ Date = $ _ POST ['Date'];
$ Conn = mysql_connect ("localhost", "root", "root ");
Mysql_query ("set names 'utf8'", $ conn );
Mysql_select_db ("ultrax", $ conn );
$ Exec = "insert into 'TM _ comment' ('playerid', 'message', 'Color', 'fontsize', 'mode', 'playtime', 'date ') VALUES ('$ vid',' $ message', '$ color',' $ fontsize ',' $ mode', '$ playtime',' $ date ')";
$ Result = mysql_query ($ exec, $ conn );
Mysql_close ($ conn );
?>





In this case

Header ('content-Type: text/xml ;');
$ Id = $ _ GET ['id'];
$ Link = mysql_connect ("localhost", "root", "root ");
Mysql_select_db ("ultrax", $ link );
$ Q = "SELECT * FROM 'TM _ comment' WHERE playerID = $ id ";
Mysql_query ("set names utf8 ");
$ Rs = mysql_query ($ q, $ link );
If (! $ Rs) {die ("Valid result! ");}
Echo" \ N ";
Echo" \ N ";
While ($ row = mysql_fetch_row ($ rs ))
Echo" $ Row [5] $ Row [1] $ Row [6] \ N ";
Echo" ";
Mysql_free_result ($ rs );
?>


Now there is a problem, my interface

Ability to write data

But it cannot be read (I have not written the wrong database IP address, user name, password, and database name)


------ Solution --------------------
$ Id = $ _ GET ['id'];
It is impossible to obtain the id here, because your database does not have the id column.
------ Solution --------------------
$ Q = "SELECT * FROM 'TM _ comment' WHERE playerID = '$ ID '";

Because 'playerid' text not null,
------ Solution --------------------
Positive solution... How to set the id to text? Use INT ..
Discussion

$ Q = "SELECT * FROM 'TM _ comment' WHERE playerID = '$ ID '";

Because 'playerid' text not null,

------ Solution --------------------
Fainted! Only when an error occurred in the data type was found !~~~

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.