[英]MySQL insert does not work
我想在mysql数据库中插入数据。当我尝试使用PHP MyAdmin插入查询然后工作时,但是如果我要从提交的php网站插入,那行将无法正常工作。
我的文字
http://www.lexisnexis.com/hottopics/gacode/
§16-11-125.1 定义
在本部分中,术语:
我的表单提交仅插入此文本
http://www.lexisnexis.com/hottopics/gacode/
我的查询
$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());
对于数据库连接,应为:
$conn = mysqli_connect('localhost', 'test', 'test') or die(mysqli_error($conn));
对于查询,应为:
mysqli_query($conn, $queryc) or die(mysqli_error($conn);
记住,mysqli_query的参数是数据库连接,也要查询,如果查询($ queryc)是:
$queryc = "INSERT INTO `table` (data17)values mysqli_real_escape_string($test))";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.