PHP to data table access data out about the problem! Solving

Source: Internet
Author: User
PHP to data table Access data out of the problem! Solving
Code:

To create a digital library data table code:
error_reporting (0); Suppress incorrect output
$link = mysql_connect (' localhost:3306 ', ' root ', '); Establish a connection
if (! $link) {
Die (' connection to MySQL service failed: '. mysql_error ());
}
echo ' Connect MySQL service successfully! ';
if (mysql_query ("CREATE DATABASE Xiaomai", $link))
{
echo "created the data table successfully!" ";
}
else {
echo "Failed to create data table!" ";
}
mysql_select_db ("Xiaomai", $link);
$sql = "CREATE TABLE student
(
Name varchar (15),
Size int,
Heigh int) ";
mysql_query ($sql, $link);
echo "

Create data table successfully! ";
Mysql_close ($link);
?>
There are no errors at run time!



Code to insert data into the data table:
form data Insertion


if ($_get[' act '] = = ' Insert ') {
error_reporting (0);
$link = mysql_connect (' localhost:3306 ', ' 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[' Heigh ')."

echo "

Insert data Successfully! ";
Mysql_close ($link);
Die ();
}
?>


Error message on the main interface! But you can insert data into the data table!

The data I entered is: My name is 116 170, the data table is shown as:? Ó???? 116 170

What is the reason?
------Optimal Solution--------------------
Since there is a mistake, why not post it?

mysql_query ("Set names GBK"); Execute this sentence before inserting

  • Related Article

    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.