Can';不要在我的php中发布长文本
这是我的Can';不要在我的php中发布长文本,php,Php,这是我的promotion.php <form action="postingPromotionUpdate.php" method="post" enctype="multipart/form-data"> Promo Title: <input type="text" name="promotionTitle"/><br/> Promo Remark: <textarea name="promotionText" cols="100" rows="1
promotion.php
<form action="postingPromotionUpdate.php" method="post" enctype="multipart/form-data">
Promo Title: <input type="text" name="promotionTitle"/><br/>
Promo Remark: <textarea name="promotionText" cols="100" rows="10" </textarea><br/>
<input type="submit" value="Update"/>
</form>
include 'connect.php';
$promotionTitle=$_POST['promotionTitle'];
$promotionText=$_POST['promotionText'];
mysql_query("update promotion set promotionTitle = '$promotionTitle', promotionText = '$promotionText' where indexNum = 1");
echo "<script>alert('Update Successful!');</script>";
如果我发短信,没问题。当我发布一个很长的文本时,我无法发布并保存它。可能是因为两个原因 1.您在mysql中的字符类型可能很短(如varchar[100]),请使用“longtext”作为字符类型 2.不使用mysql\u real\u escape\u字符串。如果文本查询中断中出现单引号。 使用此函数可恢复该值
function clean($str)
{
$str = @trim($str);
if(get_magic_quotes_gpc()) {$str = stripslashes($str); }
return mysql_real_escape_string($str);
}
$promotionTitle=clean($_POST['promotionTitle']);
$promotionText=clean($_POST['promotionText']);
如果无法在
postPromotion.php
上获取数据。然后检查php.ini
中的post\u max\u size
检查列的长度。在将其发送到SQL之前,还需要删除/替换字段中的单引号。@PeterK你是在说这个吗promotionTitle='$promotionTitle',promotionText='$promotionText'
要删除引号吗?如果是的话,没有。你提供的信息是假的。这些是字符串文字。这也不是关闭的不,不,不,不,不!请不要推荐过时的技术。OP应该学习使用PDO的语句,并考虑PDO。他问了他的代码,所以我只是告诉他,无论如何,我认为使用PDO比MyQuLi好,也许将来MySQL也会弃用。