我是教会网站的平面设计师。我没有很多编程知识,只是来到这里问问。教会在程序员之间,他们有一个问题祷告申请表。当有人输入包含撇号的请求时,它表示无法提交(查看代码,这是它无法更新数据库时应该告诉他们的内容)。这是代码:
$conn = mysql_connect('DATABASE CONNECTION GOES HERE');
mysql_select_db('DATABASE NAME', $conn) or die( "Unable to select database");
$query="INSERT INTO prayerrequests (submitdate, submitby, submitemail, prayerrequest, posted, approved) VALUES ('$today', '$user','','”.str_replace(“’”, “’’”, $request1).”',1, 1)";
$result = mysql_query($query) or die("Unable to update database");
答案 0 :(得分:0)
不确定你的双引号但我们试试这个:
http://www.php.net/manual/fr/function.mysql-real-escape-string.php
$query="INSERT INTO prayerrequests
(submitdate, submitby, submitemail, prayerrequest, posted, approved)
VALUES
('$today', '$user','','".mysql_real_escape_string($request1)."',1, 1)";