简体   繁体   English

MySQL插入不起作用

[英]MySQL insert does not work

I want to insert data in mysql database.when i am trying to insert my query using PHP MyAdmin then work but if i am tring to insert from my php site from submission the not work some text not insert. 我想在mysql数据库中插入数据。当我尝试使用PHP MyAdmin插入查询然后工作时,但是如果我要从提交的php网站插入,那行将无法正常工作。

my text 我的文字

http://www.lexisnexis.com/hottopics/gacode/ http://www.lexisnexis.com/hottopics/gacode/

§ 16-11-125.1. §16-11-125.1 Definitions 定义

As used in this part, the term: 在本部分中,术语:

my form submission insert only this text 我的表单提交仅插入此文本

http://www.lexisnexis.com/hottopics/gacode/ http://www.lexisnexis.com/hottopics/gacode/

my query 我的查询

$test='http://www.lexisnexis.com/hottopics/gacode/

§ 16-11-125.1.  Definitions 

   As used in this part, the term:';
$conn = mysql_connect('localhost', 'test', 'test') or die(mysql_error());
mysql_select_db("test") or die(mysql_error());
mysql_query('SET NAMES utf8');
mysql_query("SET CHARACTER SET utf8");
mysql_query("SET SESSION collation_connection ='utf8_unicode_ci'");

$queryc = "INSERT INTO `table` (data17)values ('".addslashes($test)."')";
mysql_query($queryc) or die(mysql_error());

for the database connection, it should be: 对于数据库连接,应为:

 $conn = mysqli_connect('localhost', 'test', 'test') or die(mysqli_error($conn));

for the query, it should be: 对于查询,应为:

mysqli_query($conn, $queryc) or die(mysqli_error($conn);

remember, the mysqli_query's arguments are database connection, query also, it would be better if the query ($queryc) was: 记住,mysqli_query的参数是数据库连接,也要查询,如果查询($ queryc)是:

$queryc = "INSERT INTO `table` (data17)values mysqli_real_escape_string($test))";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM