jjacquay712 Posted February 25, 2009 Share Posted February 25, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/146924-solved-php-auto-escaping-mysql-strings/ Share on other sites More sharing options...
premiso Posted February 25, 2009 Share Posted February 25, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/146924-solved-php-auto-escaping-mysql-strings/#findComment-771343 Share on other sites More sharing options...
jjacquay712 Posted February 25, 2009 Author Share Posted February 25, 2009 Thanks for the help, i am going to try to use this: ini_set("magic_quotes_gpc = Off"); Quote Link to comment https://forums.phpfreaks.com/topic/146924-solved-php-auto-escaping-mysql-strings/#findComment-771345 Share on other sites More sharing options...
PFMaBiSmAd Posted February 25, 2009 Share Posted February 25, 2009 magic_quotes_gpc must be turned off before your script runs. It is not settable using ini_set() in a script. Quote Link to comment https://forums.phpfreaks.com/topic/146924-solved-php-auto-escaping-mysql-strings/#findComment-771350 Share on other sites More sharing options...
jjacquay712 Posted February 25, 2009 Author Share Posted February 25, 2009 Yeah... That didn't work. How would i turn magic quotes off? Quote Link to comment https://forums.phpfreaks.com/topic/146924-solved-php-auto-escaping-mysql-strings/#findComment-771356 Share on other sites More sharing options...
jjacquay712 Posted February 25, 2009 Author Share Posted February 25, 2009 I tried setting it in my .htaccess file, and adding a php.ini file in the directory with the command to turn magic quotes off, but nothing worked. Quote Link to comment https://forums.phpfreaks.com/topic/146924-solved-php-auto-escaping-mysql-strings/#findComment-771363 Share on other sites More sharing options...
premiso Posted February 25, 2009 Share Posted February 25, 2009 Are you on shared hosting? Quote Link to comment https://forums.phpfreaks.com/topic/146924-solved-php-auto-escaping-mysql-strings/#findComment-771367 Share on other sites More sharing options...
jjacquay712 Posted February 25, 2009 Author Share Posted February 25, 2009 I got it working, had to mess with the htaccess file Quote Link to comment https://forums.phpfreaks.com/topic/146924-solved-php-auto-escaping-mysql-strings/#findComment-771368 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.