douquanjie9326 2009-06-08 01:19
浏览 37
已采纳

PHP:在MDB2中使用MYSQL对字符串使用quote()

I'm using Pear's MDB2 and really enjoying it, but there is something that is starting to annoy me. I build the SQL string in the following way, using the quote method of the mdb2 package:

$sql = sprintf("INSERT INTO profiles(email, fullName) VALUES(%s,%s)", 
                     $mdb2->quote($email), $mdb2->quote($fullName));

(as explained in the example on this page: http://pear.php.net/manual/en/package.database.mdb2.intro-quote.php)

and everything looks nice in the database. But when I extract data from the database, still using MDB2 I can't seem to find an easy way of stripping the quoting added by the quote method. At the moment I am using the stripslashes, but this doesn't seem right. Am I missing a setting somewhere? I am I using the package in the wrong way?

Thank you for you help, Leif

  • 写回答

1条回答 默认 最新

  • douzhicui2209 2009-06-08 01:21
    关注

    I've found that turning off magic_quotes_gpc, and magic_quotes_runtime, to be the best approach. In fact, as of 5.3.0 these directives have been deprecated. In 6.0 they have been removed all together.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?