Insert data in PHP can only insert numbers and letters cannot be inserted into the text solution
Source: Internet
Author: User
Insert data in PHP can only insert numbers and letters can't insert text
I first used $_post to get two of the form's data and then submit it to the page that executed the SQL statement, but I always couldn't insert the text.
+++++++++++++++++++++++++++++++++++++++++++++++++++++
Require "777.php";
mysql_query ("Set names ' Utf-8");
mysql_query ("SET NAMES ' GB2312 '");
$sql = mysql_query ("Select*from lyb"); Output message Content
/*
* Created on 2012-4-3
*
* To change the template for this generated file go to
* Window-preferences-phpeclipse-php-code Templates
*/
Require "777.php";
if ($_post[submit]!= "") {
------Solution--------------------
Does your first piece of code have output? What can you see?
mysql_query ("Set names ' Utf-8");
should be for
mysql_query ("Set names ' UTF8");
If your program file is UTF-8 encoded, use the
mysql_query ("Set names ' UTF8");
If your program file is GBK encoded, use the
mysql_query ("SET NAMES ' GB2312 '");
Better be
mysql_query ("SET NAMES ' GBK '");
Choose one of the two
The second piece of code does not have a language declaration, even if it is inserted, it may be garbled
$sql = "INSERT into Lyb (user,post) VALUES (' $user ', ' $post ')";
$qu = mysql_query ($sql) or Die (Mysql_error ());
See what's wrong with the report.
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.