Page 1 of 1
New to php
Posted: Wed Jan 23, 2008 4:57 pm
by dmwesq
Just getting started, and as per the book I'm using, I created a simple form.
Code: Select all
<?php
echo "<p>Welcome <b>".$_POST["user"]."</b>!</p>";
echo "<p>Your message is:<br/><b>".$_POST["message"]."</b></p>";
?>
Here is what was entered in the message:
Code: Select all
This is a test. You're the best!!!
Somehow, in the output, there is a slash in the word You're:
Code: Select all
Welcome Dan!
Your message is:
This is a test. You\'re the best!!!
Any idea where that slash came from? It doesn't appear in the code on this page, but it does show in the browser - tried it in Firefox and Safari.
Re: New to php
Posted: Wed Jan 23, 2008 5:01 pm
by Christopher
Your PHP configuration is probably set to add slashes to request variables. There are functions to strip slashes.
Re: New to php
Posted: Wed Jan 23, 2008 10:26 pm
by dmwesq
arborint wrote:Your PHP configuration is probably set to add slashes to request variables. There are functions to strip slashes.
Where would I find such a function?
More importantly, when you are not hostng the php yourself but are relying on the server of the host, how do you access files such as php.ini if need be? I see the file on the server directory, which is a Linux server. Do I need to download that file to my hard drive to edit it, and can I edit that in a Mac environment and then upload it again to the Linux-based server?
Re: New to php
Posted: Wed Jan 23, 2008 11:07 pm
by Christopher
dmwesq wrote:Where would I find such a function?
Here
dmwesq wrote:More importantly, when you are not hostng the php yourself but are relying on the server of the host, how do you access files such as php.ini if need be? I see the file on the server directory, which is a Linux server. Do I need to download that file to my hard drive to edit it, and can I edit that in a Mac environment and then upload it again to the Linux-based server?
If you can edit the php.ini file and restart the web server, then do that. Otherwise, you can call functions within your scripts to change some settings. And there are functions like I mentioned above to modify values.
Re: New to php
Posted: Thu Jan 24, 2008 1:46 am
by Kieran Huggins
The slash is added due to something called "escaping" - the server you're on seems to be a little whacked, since this hasn't been an issue in quite some time. (since PHP 4.3 I think?)
The setting that's causing this is
magic_quotes_gpc and PHP6 will be removing it altogether.
I'd strongly recommend you just shut it off. In your .htaccess file, add the line:
and be done with it!