Jump to content

[SOLVED] PHP Auto Escaping MySQL Strings


jjacquay712

Recommended Posts

I have a database manager script that I am working on, kind of like phpmyadmin. When a user types in their custom query, it automatically escapes semi quotes.

 

example:

User inputted query: 
SELECT * FROM users WHERE username='Joe';

What php does:
SELECT * FROM users WHERE username=\'Joe\';

 

Is there anyway to make php not do this?

Link to comment
https://forums.phpfreaks.com/topic/146924-solved-php-auto-escaping-mysql-strings/
Share on other sites

You are over escaping the data.

 

Check that magic_quotes is turned off, if not turn it off. You may have to stripslashes on current data then update it for it to be right in the current DB.

 

Basically with magic_quotes on, php adds addslashes to any form data passed to the script. It is being depreciated/turned off in PHP 6. So I suggest not relying on it and just turn it off and be happy :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.