[SOLVED] Dont touch my code

07-11-08, 03:27 PM
|
 |
Code Master
|
|
Join Date: Jun 2003
Location: North East England/UK
Posts: 874
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
[SOLVED] Dont touch my code
In relation to the post strip_tags or htmlspecialchars I actually need the reverse.
I have a area where my code is saved and then loaded back into the page. The problem is, and Im sure Ive never had this problem before on previous installs of PHP, is that all html characters are encoded to & lt; and & gt; for the < >. which is not good when I load the html up as its just a block of code instead of actually being HTML. I thought I could correct this after I stripslashes then run html_entity_decode but it doesnt do anything. Since the world of encoding is a complex ever-changing subject and my basic foundations seem to have slipped away from me Im in need of help.
Quote from tizag.com.
Quote:
The htmlentities function takes a string and returns the same string with HTML converted into HTML entities. For example, the string "<script>" would be converted to "<script>".
By converting the < and > into entities, it prevents the browser from using it as an HTML element and it prevents the code from running if you were to display some user's input on your website.
|
Even tizag describes it as the way I thought it worked but it doesnt. Im not sure but does the fact that the file is xhtml have anything to do with it?
Thanks
Dal
__________________
"once upon a midnight dreary, while i pron surfed, weak and weary, over many a strange and spurious site of 'hot xxx galore'. While i clicked my fav'rite bookmark, suddenly there came a warning, and my heart was filled with mourning, mourning for my dear amour," 'Tis not possible!", i muttered, "give me back my free hardcore!" quoth the server, 404."
|

07-11-08, 05:09 PM
|
 |
-
|
|
Join Date: Feb 2006
Posts: 2,515
Thanks: 20
Thanked 109 Times in 106 Posts
|
|
|
|

07-11-08, 05:25 PM
|
 |
Code Master
|
|
Join Date: Jun 2003
Location: North East England/UK
Posts: 874
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
Originally Posted by wirehopper
|
Thanks wirehopper but Ive already tried this.
Quote:
|
"I thought I could correct this after I stripslashes then run html_entity_decode but it doesnt do anything."
|
__________________
"once upon a midnight dreary, while i pron surfed, weak and weary, over many a strange and spurious site of 'hot xxx galore'. While i clicked my fav'rite bookmark, suddenly there came a warning, and my heart was filled with mourning, mourning for my dear amour," 'Tis not possible!", i muttered, "give me back my free hardcore!" quoth the server, 404."
|

07-11-08, 05:28 PM
|
 |
Community Leader
|
|
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
|
|
Can you post? Sounds more like an error on your side.
|

07-11-08, 06:23 PM
|
 |
Code Master
|
|
Join Date: Jun 2003
Location: North East England/UK
Posts: 874
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Sure Nico
The project is alot bigger than this but this is the part I cant get to work.
Anyway, to test it simply copy some html into the text area ie
Click save to $_POST is back to the form and auto populate the text area then use the javascript function to write the contents over to the div.
Thanks
OOPS = I had a few mistakes in my above example. That should work now. Maybe its the javascript side thats causing my issues. I never thought to check. ?? Im unsure though because I use a javascript function to copy the html into the text area in my main project so I would know if its js thats causing the convert.
__________________
"once upon a midnight dreary, while i pron surfed, weak and weary, over many a strange and spurious site of 'hot xxx galore'. While i clicked my fav'rite bookmark, suddenly there came a warning, and my heart was filled with mourning, mourning for my dear amour," 'Tis not possible!", i muttered, "give me back my free hardcore!" quoth the server, 404."
Last edited by DAL; 07-11-08 at 06:38 PM.
Reason: Im a plonka! Example code didnt work. Now Corrected
|

07-12-08, 10:18 AM
|
 |
Code Master
|
|
Join Date: Jun 2003
Location: North East England/UK
Posts: 874
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Ive uploaded the script so it will be easy for anyone to test what I mean.
Simply enter something like
into the text area then click "Save" then when the page refeshes click "Writeback"
As you can see it writes
"<div>Some sample text</div>"
code = <div>Some sample text</div>
instead of
"Some sample text"
code = <div>Some sample text</div>
__________________
"once upon a midnight dreary, while i pron surfed, weak and weary, over many a strange and spurious site of 'hot xxx galore'. While i clicked my fav'rite bookmark, suddenly there came a warning, and my heart was filled with mourning, mourning for my dear amour," 'Tis not possible!", i muttered, "give me back my free hardcore!" quoth the server, 404."
|

07-12-08, 11:44 AM
|
 |
Code Master
|
|
Join Date: Jun 2003
Location: North East England/UK
Posts: 874
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Through further testing I have found it to be a javascript error. (Please move my post to Javascript)
Original;
modified;
Who would have 'funk it' eh! 
Obvously no-one in here (PHP discussion)
__________________
"once upon a midnight dreary, while i pron surfed, weak and weary, over many a strange and spurious site of 'hot xxx galore'. While i clicked my fav'rite bookmark, suddenly there came a warning, and my heart was filled with mourning, mourning for my dear amour," 'Tis not possible!", i muttered, "give me back my free hardcore!" quoth the server, 404."
Last edited by DAL; 07-12-08 at 11:45 AM.
Reason: BBcode tags modified
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|