Sign in to follow this  
Talib

[web] Strange single quote issue (Textbox, PHP, MySQL)

Recommended Posts

Talib    170
Hi I'm kinda new to PHP and MySQL and so I decided to write a webpage with a textbox where I can type in my SQL statements and perform them via a submit button. Just to speed things up. When I type an SQL statement where I need to use single quotes to indicate a string I get different results on different machines. On my local machine the quotes stay the same, but on the online server the quotes get translated to a \'. I can work around this, but I would just like to know where the difference comes in. Local Machine: Windows XP SP2 PHP ver 5 MySQL ver 5 IIS Online Server: Linux 2.6.17.11-grsechg PHP ver 4.4.1 MySQL ver 4.1.21-standard Apache ver 1.3.34 (Unix)

Share this post


Link to post
Share on other sites
Mathachew    352
The only thing I can think of is that magic quotes is enabled on the online server.

You can edit php.ini and set it to Off. If you do this, you'll need to restart Apache.

Share this post


Link to post
Share on other sites
Lesan    440
Yes, the magic quotes are probably on.

* If you are the administrator of that online server, you can edit php.ini. But then your webserver can be vulnerable. You shouldn't allow anyone to manipulate with MySQL database on your own server.

* If it is some sort of webhosting, mostly you don't have a possibility to modify php.ini. Then you can use PHP function stripslashes(input string).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this