[英]Saving text from Textarea in mysql database with php (apostrophes)
html
<form id = "recall_TextArea2" method="post" action="SaveRecall2.php">
<center><textarea name="recall_Info" cols="60" rows="30em"></textarea></center>
</form>
的PHP
if (isset($_POST['recall_Info'])) {
$recall_Info = $_POST['recall_Info'];
}
else {
echo "nothing was recalled.";
}
$recall_Info = stripslashes($recall_Info);
$recall_Info = mysqli_real_escape_string($recall_Info);
$update_sql = "UPDATE `participants` SET `recall_1` = '$recall_Info' WHERE `school_id` =825776 LIMIT 1 ;";
我希望能够在带有撇号的文本区域中输入文本,但是每次尝试都无法正常工作。
当我取出时,它会保存普通文本(没有撇号)
$recall_Info = stripslashes($recall_Info);
$recall_Info = mysqli_real_escape_string($recall_Info);
我想看看您是否正在正确访问表单/帖子数据。 也许在sql之前先回显您的表单数据,以查看发生了什么情况。
这对我有用,我没有更改您的sql查询:
$username = "root";
$password = "root";
$host = "localhost";
$dbname = "test";
$mysqli = new mysqli($host, $username, $password, $dbname);
$recall_Info ="this is new recall info text";
$update_sql = "UPDATE `participants` SET `recall_1` = '$recall_Info' '' WHERE `school_id` ='825776' LIMIT 1;";
$stmt = $mysqli->stmt_init();
$stmt->prepare($update_sql);
$stmt->execute();
if ($stmt->affected_rows > 0) {
$OK = true;
}
if ($OK) {
echo 'update successful';
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.