开发者

Issue in the inserting text in the model to database on Zend Framework

I am new in the "Zend Framework". So I ran into some problems.

First of them is inserting text into database. e.g. i am inserting something like this " wha开发者_StackOverflowt's happening" and in the view appears "what\'s happening now" and symbol " \' " appears there.

Second, submiting text to controller like this(with html encoded symbols) "whats  happening" and only "whats" reaches the controller.

Please help me to solve these problems?


There is an old PHP feature called magic quotes where PHP would automatically escape any post/get data to make it 'easy' to insert into a database. See http://php.net/manual/en/security.magicquotes.php. It is likely to be this that is adding the quotes to your content. This feature has been deprecated, so I would recommend disabling it in your php.ini file (or htaccess) which should solve your problem. Assuming you are using mod_php, just add this to a .htaccess file:

php_flag magic_quotes_gpc Off

ZF will automatically escape content on insertion (assuming you are using Zend_Db correctly), so the issue you're having is because the data is being escaped twice.

Can you provide a little more info about your second question, e.g. how you are submitting the text and how you are using it in the controller?


I never used ZF, but I can tell you the which functions you need to study for sanitizing the input/output

During insertion into database

  • addslashes()
  • mysql_real_escape_string()

During display on Browser

  • stripslashes()
  • htmlspecialchar()
  • htmlentities()
  • htmlspecialchars_decode
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜