一樣的資料ie發送後伺服器返回的情況不一樣

來源:互聯網
上載者:User
同樣的資料ie發送後伺服器返回的情況不一樣
求教一個問題
同樣的參數傳輸,ie瀏覽器和其他的伺服器響應不一致,post方式
前台jquery,使用escape對foldername進行了轉碼,後台是
$par['foldername']=unescape($par['foldername']);
$mids=explode(',',$par['mid']);//需要刪除的郵件清單
$res['sql']=$par['foldername']; //debug1
if($par['foldername']=="已刪除" || $par['foldername']=="草稿箱"){
$par['delete']=true;//垃圾箱內的徹底刪除掉
$res['sql'].=' AA'.$par['foldername']; //debug2
}

結果發現在ie下不進入$par['delete']=true;這個if判斷,求解

ff查看返回,能返回“已刪除 AA已刪除”這樣滿足邏輯的東西,而ie請求的話則只返回“已刪除”,if根本就不進去,求解

分享到: 更多


------解決方案--------------------
echo $par['foldername'];
看看是什麼
------解決方案--------------------
在ie下列印下unescape前後的 $par['foldername'];看下結果
------解決方案--------------------
$res['sql'].=' AA'.$par['foldername']; //debug2

這樣的寫法很怪
------解決方案--------------------
$par['foldername'] = trim($par['foldername']);

至於是如何多出的,需要看到你的頁面代碼
------解決方案--------------------
如果欄位是char或varchar類型,那麼在字串比較的時候MySQL使用PADSPACE校對規則,會忽略欄位末尾的空白字元,若想做到精確匹配可以使用下面幾種方法:
方法1:使用like語句;
方法2:使用binary類型,例如,select binary 'a' = 'a '
方法3:再添加一個length()條件,例如,select col from table where col = 'a ' and LENGTH(col) = LENGTH('a ')

官方手冊說明(5.0版本):
http://dev.mysql.com/doc/refman/5.0/en/char.html
11.1.6.1. The CHAR and VARCHAR Types
All MySQL collations are of type PADSPACE. This means that all CHAR, VARCHAR, and TEXT values in MySQL are compared without regard to any trailing spaces. “Comparison” in this context does not include the LIKE pattern-matching operator, for which trailing spaces are significant.
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.