Wordpress Database Output - Remove SQL Injection Escapes

自古美人都是妖i 提交于 2020-01-01 17:07:18

问题


I'm having a problem using $wbdb. When I insert or update data using $wpdb->insert or $wpdb->update, the SQL injection protection actually inserts the \' into the database, and when outputting that information it has the SQL escape with it. (ie: My Value\'s Escaped).

I know there's gotta be a way to escape this using a wordpress function, but I haven't been able to find it searching google and the wordpress codex. ...So what's that function, or what am I doing wrong (seems like the '\' shouldn't really get to the database in the first place) Thanks!


回答1:


It looks as if magic_quotes are enabled on the server you are using.

There are a number of SO questions and answers that deal with what they are, why they're bad, and how to get rid of them, so I won't explicitly explain here, but suggest you look at a few of the following:

  • Magic quotes in PHP
  • Work around magic quotes, or just make sure they're off?
  • How can I disable PHP magic quotes at runtime?
  • How to turn off magic quotes on shared hosting?
  • PHP protecting itself from SQL injections?


来源:https://stackoverflow.com/questions/1739875/wordpress-database-output-remove-sql-injection-escapes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!