Technical Help & Discussion > Website Design & Programming
PHP
Hiatus:
Yep, all the functions are compatible. The only one that wouldn't compatible is file_put_contents() if I were using it, which I wish I could...but it only work in PHP 5.
I think the problem occurs during POST. The htmlentities() function works fine. What it does (if anyone was wondering) is converts the "<" and ">" and a few other things to "words". "<" would become < and ">" would become >. Therefore, the html code will not render itself to display as a page, but rather as text.
Anyways, what confuses me is that you are supposed to use html_entity_decode() to decode the html and change < back to "<", etc., etc. But, I didn't have to do this. I'm thinking that during the POST stage, it decodes all the tags and also somehow messes it up, adding the \'s in.
I don't know...this is too confusing :?
sam:
ok!! I now have realised the problem!! php adds these tags! give me a minute i think i have your solution...
sam:
you are indeed correct that it is the POST bit that is going wrong, from php.net:
--- Quote --- The PHP directive magic_quotes_gpc is on by default, and it essentially runs addslashes() on all GET, POST, and COOKIE data.
--- End quote ---
So what you need to do is turn off this.
Firstly it would be worth checking if this is on, just in case it is something else, to do this you can use the following php script:
--- Code: ---<?php
highlight_string ( "<?php
if (get_magic_quotes_gpc()==1) {
echo ( "Magic quotes gpc is on" );
} else {
echo ( "Magic quotes gpc is off" );
}
?>" );
?>
--- End code ---
If this is the case you can get around this by using the following code (put it near the top:
--- Code: ---if (get_magic_quotes_gpc()) {
// Yes? Strip the added slashes
$_POST = array_map('stripslashes', $_POST);
}
--- End code ---
You can also turn this off by putting a .htaccess file in the directory where the script runs from containing:
For php4
--- Code: ---<?php
highlight_string ( "<IfModule mod_php4.c>
php_flag magic_quotes_gpc off
</IfModule>" );
?>
--- End code ---
For php3
--- Code: ---<?php
highlight_string ( "<IfModule mod_php3.c>
php3_flag magic_quotes_gpc off
</IfModule>" );
?>
--- End code ---
but you might not want to do this if you are reading to a database.
sam:
oh and more info can be found at:
http://uk.php.net/stripslashes
http://uk2.php.net/manual/en/function.get-magic-quotes-gpc.php
http://uk.php.net/addslashes
hope this resolves your issue...what you doing with the code btw (overall aim I mean)?
Hiatus:
Beautiful! It worked!
That's awesome, thanks man.
I am using the code so that I can login to my site from anywhere and edit it. Just in case I have to change or add something quickly, and I can't get to my computer to do it.
Anyways, thanks again!
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version