A problem occurs when PHP requests data from the data table! Solution

Source: Internet
Author: User
An error occurred while entering/picking data from the data table in PHP! Solution code: create a digital database data table code: & lt ;? Phperror_reporting (0); & nbsp; & an error occurred while receiving data from the data table in nbs PHP! Solution
Code:

Code for creating a digital database data table:
Error_reporting (0); // disable error output
$ Link = mysql_connect ('localhost: 100', 'root', ''); // establish a connection
If (! $ Link ){
Die ('connection to MySQL service failed: '. mysql_error ());
}
Echo 'connection to MySQL service successful! ';
If (mysql_query ("create database xiaomai", $ link ))
{
Echo "data table created! ";
}
Else {
Echo "an error occurred while creating the data table! ";
}
Mysql_select_db ("xiaomai", $ link );
$ SQL = "CREATE TABLE student
(
Name varchar (15 ),
Size int,
Heigh int )";
Mysql_query ($ SQL, $ link );
Echo"

Data table created! ";
Mysql_close ($ link );
?>
No errors during running!



Code for inserting data into a data table:
Insert form data


If ($ _ GET ['AC'] = 'insert '){
Error_reporting (0 );
$ Link = mysql_connect ('localhost: 100', 'root', ''); // establish a connection
If (! $ Link ){
Die ('connection to MySQL service failed: '. mysql_error ());
}
Mysql_select_db ("xiaomai", $ link );
Mysql_query ("insert into student (name, size, heigh) VALUES ('". $ _ POST ['name']. "','". $ _ POST ['size']. "',
'". $ _ POST ['hei']."') ");

Echo"

Data inserted! ";
Mysql_close ($ link );
Die ();
}
?>


An error message is displayed on the main interface! But you can insert data into the data table!

The data I entered is: My name is 116 170, but the data table is displayed :? Ó ???? 116 170

Why?
------ Best solution --------------------
Why not post the error message?

Mysql_query ("set names gbk"); // execute this statement before insertion.

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.