dongrao1862 2013-02-07 12:13
浏览 61

关闭PHP中的魔术引用似乎不起作用

I am trying to turn magic quotes off in PHP but cannot get it to disable - I have set the below in /usr/local/lib/php.ini and restarted Apache but it has made no difference.

; Magic quotes

; Magic quotes for incoming GET/POST/Cookie data.
magic_quotes_gpc = Off

; Magic quotes for runtime-generated data, e.g. data from SQL, from exec(), etc.
magic_quotes_runtime = Off

; Use Sybase-style magic quotes (escape ' with '' instead of \').
magic_quotes_sybase = Off

phpinfo confirms these are all set to Off.

magic_quotes_gpc Off Off
magic_quotes_runtime Off Off
magic_quotes_sybase Off Off

I then tried adding

php_flag magic_quotes_gpc off 

to htaccess but that gives a 500 Internal Server error - looking in error_log there is nothing added to tell me why this might be happening.

Server is running Centos 5.8 64 bit with CPanel/WHM and the front end is Wordpress with a custom PHP application in the background. PHP version is 5.3.18 and Loaded Configuration File is /usr/local/lib/php.ini

The reason I think it is not working is that the following message which is pulled from MySQL where it had mysql_real_escape_string, addslashes and htmlspecialchars applied to it before adding to the database.

The original message is:

This is a "how to" question. I don't think it is covered in the notes - sorry if I've missed it. 

It gets added to MySQL as:

This is a "how to" question. I don\'t think it is covered in the notes - sorry if I\'ve missed it.

When it is then displayed on the screen it displays as:

This is a \\"how to\\" question. I don\\\'t think it is covered in the notes - sorry if I\\\'ve missed it. 

And when stripslashes is then applied to this, it becomes:

This is a \"how to\" question. I don\'t think it is covered in the notes - sorry if I\'ve missed it. 

What am I doing wrong or what else can I try?

  • 写回答

1条回答 默认 最新

  • duanqinqiao4844 2013-02-07 13:49
    关注

    \" is not the result of magic quotes or addslashes().

    Plus, I can't think of a standard PHP quoting function that would replace double quotes with \" and escapes single quotes with a slash. You've got something deeper wrong with your code.

    评论

报告相同问题?

悬赏问题

  • ¥15 yolov8边框坐标
  • ¥15 matlab中使用gurobi时报错
  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真