Problem with escape characters

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
canam101
-


Joined: 15 Jan 2007
Posts: 9

PostPosted: Fri Jan 19, 2007 12:54 am    Post subject: Problem with escape characters Reply with quote

I am running a small html form that calls a php module.

The php module writes out the information entered on the html form, but every time someone enters an apostorphe, what gets written out by the php module is \'

A quote (") becomes \"

A backslash (\) becomes \\

There are probably more of these lying in wait. Any idea as to what could be causing this?

Here's the html:

<center><span style="font-weight: bold;">Your Message</span><br>
<textarea cols="68" rows="7" name="message">Enter your message here</textarea><br>


Here's the php:

$filename = 'message.txt'; // Save information to this file
$abcFile = fopen("$filename","w"); // Open File
fputs($abcFile,$message); // Write data (put) to File
fclose($abcFile); // Close data.txt File
Back to top View user's profile Send private message
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Fri Jan 19, 2007 1:11 am    Post subject: Re: Problem with escape characters Reply with quote

canam101,

You must set magic_quotes_gpc to no (or false) in your php.ini. More information is available in http://www.php.net/manual/en/ref.info.php#ini.magic-quotes-gpc .
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
canam101
-


Joined: 15 Jan 2007
Posts: 9

PostPosted: Fri Jan 19, 2007 1:51 am    Post subject: Re: Problem with escape characters Reply with quote

aprelium wrote:
canam101,

You must set magic_quotes_gpc to no (or false) in your php.ini. More information is available in http://www.php.net/manual/en/ref.info.php#ini.magic-quotes-gpc .


Thanks for the quick response. On my debian linux pc, it looks like /usr/share/php5/php.ini-dist is the ini file. I turned the magic_quotes_gpc to Off, but it did not have any effect. Still getting the backslashes.

I rebooted too, just in case, but it did not make any difference.
Back to top View user's profile Send private message
roganty
-


Joined: 08 Jun 2004
Posts: 357
Location: Bristol, UK

PostPosted: Fri Jan 19, 2007 11:42 am    Post subject: Re: Problem with escape characters Reply with quote

canam101 wrote:
Thanks for the quick response. On my debian linux pc, it looks like /usr/share/php5/php.ini-dist is the ini file. I turned the magic_quotes_gpc to Off, but it did not have any effect. Still getting the backslashes.

I rebooted too, just in case, but it did not make any difference.


Are you sure that is the correct path to the php.ini file?

If you use the phpinfo() function the path to the php.ini is displayed under the "Configuration File (php.ini) Path"
_________________
Anthony R

Roganty
| Links-Links.co.uk
Back to top View user's profile Send private message Visit poster's website
hc2995
-


Joined: 07 Aug 2006
Posts: 644
Location: Maryland, USA

PostPosted: Fri Jan 19, 2007 1:45 pm    Post subject: Reply with quote

php.ini-dist is not the php.ini file, i have php.ini-dist and php.ini (and php.ini-optimizer and php.ini-zend all of them with different configurations for different features) you need to fin php.ini, if you dont have one you need to make ones (use php.ini-dist and rename it php.ini) if php was working then you most likly have a php.ini, do this then:

Open the text editor and put <?php phpinfo(); ?> in it, save the file as SOMETHING.php, then place it in your htdocs folder. Next navigate to that file, you will see a table (a big long one) look for something saying "Location of ini file" then go to that location (that is the ini file that is being used, the path will look something like this /usr/USERNAME/LOCATION_OF_PHP_FOLDER/php.ini)
_________________
Where have i been? School got heck-tick, had to move half way around the state, then back... and then i had to change jobs, so iv been away for a while :P
Back to top View user's profile Send private message AIM Address
canam101
-


Joined: 15 Jan 2007
Posts: 9

PostPosted: Fri Jan 19, 2007 4:11 pm    Post subject: Reply with quote

Thank you gentlemen. That phpinfo utility is quite the thing, and showed me that the ini file is in /etc/php5/cgi/php.ini.

I changed it as I was advised to and it fixed the problem.

I swear I could not find mention of that file in the synaptic list of files for php5, but it's probably an oversight on my part.

Thanks again.
Back to top View user's profile Send private message
hc2995
-


Joined: 07 Aug 2006
Posts: 644
Location: Maryland, USA

PostPosted: Fri Jan 19, 2007 9:35 pm    Post subject: Reply with quote

canam101 wrote:
Thank you gentlemen. That phpinfo utility is quite the thing, and showed me that the ini file is in /etc/php5/cgi/php.ini.

I changed it as I was advised to and it fixed the problem.

I swear I could not find mention of that file in the synaptic list of files for php5, but it's probably an oversight on my part.

Thanks again.


No problem, good luck on your site :D
_________________
Where have i been? School got heck-tick, had to move half way around the state, then back... and then i had to change jobs, so iv been away for a while :P
Back to top View user's profile Send private message AIM Address
Gannyaa
-


Joined: 29 Sep 2006
Posts: 93
Location: Nelson, BC -- Canada

PostPosted: Tue Jan 23, 2007 4:25 pm    Post subject: I was having the same problem .... so Reply with quote

I was having the same problem .... and still have it.
I am new to learning PHP and Abyss. And I was working on a comment script for an ebook page. I have magic quotes all set off in my php.ini

My solution around the problem was to do a string replace

Code:
   $message = strip_tags($message);
   $message = str_replace("'", "& # 3 9 ;", $message);


This way with the & # 3 9 ; replacing single quotes, user's could now use the single quote with words like it's, user's, we've, i've, i'd, couldn't, etc.

Am I missing something?

ps I put spaces between the alt code so the alt code wouldn't be converted by this edit post.
_________________
Todd (Gannyaa)
http://iGannyaa.bebo.com/
http://haidavision.no-ip.info/gannyaa/newblog.htm
Back to top View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group