本人不擅長(zhǎng)寫(xiě)正則,正則部分 你自己看著寫(xiě)吧
創(chuàng)新互聯(lián)是一家專注于成都網(wǎng)站制作、網(wǎng)站建設(shè)與策劃設(shè)計(jì),鳳縣網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)做網(wǎng)站,專注于網(wǎng)站建設(shè)10余年,網(wǎng)設(shè)計(jì)領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:鳳縣等地區(qū)。鳳縣做網(wǎng)站價(jià)格咨詢:13518219792
步驟 1 首先測(cè)試整理products_short_description
1.1 定義一個(gè) 變量?jī)?nèi)容為 products_description 的某一個(gè)完整內(nèi)容
1.2 用正則過(guò)濾掉不想要的東西, 將想要的東西整理好
注:這個(gè)做完 你已經(jīng)完成很大一部分內(nèi)容了
2 備份數(shù)據(jù)庫(kù)表 products,將products復(fù)制成 products_test表。為了測(cè)試 不破壞products表
3 查詢出products_test表內(nèi)容 。獲取到每行數(shù)據(jù)的時(shí)候 執(zhí)行下 步驟1 的內(nèi)容
4 將步驟一相關(guān)正確的結(jié)果 放置到一個(gè)數(shù)組中 產(chǎn)品id為key ,形成的正確結(jié)果為value
5 最終 遍歷正確的數(shù)組。 執(zhí)行更新 products_test 表
6 當(dāng)確認(rèn) 以上無(wú)誤 ,那你就可以更改products 表了
function deletehtml($str) {
$str = trim($str);
$str = preg_replace("/P","1234a3211",$str);
$str = preg_replace("/p","1234a3211",$str);
$str = preg_replace("br/","1234a3211",$str);
$str = preg_replace("/(.[^]*)/","",$str);
$str = preg_replace("/([\r\n])[\s]+/","",$str);
$str = preg_replace("/--/","",$str);
$str = preg_replace("/!--.*/","",$str);
$str = preg_replace("/(quot|#34);/","",$str);
$str = preg_replace("/(amp|#38);/", "http://",$str);
$str = preg_replace("/(lt|#60);/", "http://",$str);
$str = preg_replace("/(gt|#62);/", "",$str);
$str = preg_replace("/(nbsp|#160);/", "",$str);
$str = preg_replace("/(iexcl|#161);/", "/\xa1/",$str);
$str = preg_replace("/(cent|#162);/", "/\xa2/",$str);
$str = preg_replace("/(pound|#163);/", "/\xa3/",$str);
$str = preg_replace("/(copy|#169);/", "/\xa9/",$str);
$str = preg_replace("/(\d+);/", "",$str);
$str = preg_replace("http://", "",$str);
$str = preg_replace("http://", "",$str);
$str = preg_replace("/\r\n/", "",$str);
$str = preg_replace("/1234a3211/", "/br//",$str);
return $str;
}
form表單demo:task.html
fieldset id="setFiled"
legend發(fā)布任務(wù)/legend
form action="registr.php" method="post" id="steForm"
label任務(wù)類型:/labelbr
input type="text" name="type"? id="taskType" placeholder="請(qǐng)選擇任務(wù)類型"/br
label酬nbsp;nbsp;金:/labelbr
input type="number" name="money" id="forMoney" min="1" max="1000"/label元/labelbr
label截止時(shí)間:/labelbr
input type="datetime" name="time" id="timeSubmit"/span data-year="" data-month="" data-date="" id="showDate"/spanbr
label詳細(xì)描述:/labelbr
textarea maxlength="512" name="textAray" id="msgArea"/textareabr
input type="submit" name="subMit" id="forSub" value="點(diǎn)擊發(fā)布" /
/form
擴(kuò)展資料
php接收POST數(shù)據(jù)的三種方式
1、$_POST 方式接受數(shù)據(jù)
$_POST 方式是由通過(guò)HTTP的POST方法傳遞過(guò)來(lái)的數(shù)據(jù)組成的數(shù)組,是一個(gè)自動(dòng)全局變量。
注:只能接收Content-Type:application/x-www-form-urlencode提交的數(shù)據(jù)。也就是只能接收表單過(guò)來(lái)的數(shù)據(jù)。
2、GLOBLES[‘HTTP_RAW_POST_DATA’]
如果訪問(wèn)原始POST數(shù)據(jù)不是php能夠識(shí)別的文檔類型,比如:text/xml 或者soap等等,可以用$GLOBLES[‘HTTP_RAW_POST_DATA’]來(lái)接收,$HTTP_RAW_POST_DATA變量包含有原始POST數(shù)據(jù)。此變量?jī)H在碰到未識(shí)別的MIME數(shù)據(jù)時(shí)產(chǎn)生。
注:$HTTP_RAW_POST_DATA對(duì)于enctype=”multipart/form-data”表單數(shù)據(jù)不可用,也就是說(shuō)使用$HTTP_RAW_POST_DATA無(wú)法接受網(wǎng)頁(yè)表單post過(guò)來(lái)的數(shù)據(jù)。
3、file_get_contents(“php://input”);
如果訪問(wèn)原始POST數(shù)據(jù),更好的方法是使用file_get_content(“php://input”);對(duì)于未指定Content-Type的POST數(shù)據(jù),可以使用該方法讀取POST原始數(shù)據(jù),包括二進(jìn)制流也可以和$HTTP_RAW_POST_DATA比起來(lái)。它帶來(lái)的生存眼里更小,并且不需要任何特殊的php.ini設(shè)置。
注:php://input不能用于 enctype=”multipart/form-data”
例如:$postStr = file_get_contents("php://input"); //獲取POST數(shù)據(jù)
你這個(gè)問(wèn)題我之前做項(xiàng)目的時(shí)候也遇到過(guò),你可以從數(shù)據(jù)入庫(kù)時(shí)入手解決,具體做法就是你可在把數(shù)據(jù)存入到數(shù)據(jù)的時(shí)候用strip_tags()函數(shù)剝離HTML標(biāo)簽,這樣你在查詢的時(shí)候就不會(huì)遇到這種情況了,完全都是數(shù)據(jù),如果存入數(shù)據(jù)庫(kù)的數(shù)據(jù)必須要有HTML標(biāo)記的話那入庫(kù)的時(shí)候可以考慮用htmlspacialchars()函數(shù),希望能夠幫到你
分享標(biāo)題:php寫(xiě)入數(shù)據(jù)庫(kù)過(guò)濾 php數(shù)據(jù)庫(kù)語(yǔ)句
本文鏈接:http://muchs.cn/article8/dohosop.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站導(dǎo)航、網(wǎng)站設(shè)計(jì)公司、網(wǎng)站改版、外貿(mào)建站、品牌網(wǎng)站建設(shè)、外貿(mào)網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)