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.