nuttycoder Posted August 21, 2007 Share Posted August 21, 2007 I am building a tutorial site, all is working apart from 1 thing. If i type in some php code even basic stuff like Code: <?php echo date ('Y'); ?> then when its submitted into the database the php gets stripped away i'm using the tinymce editor if that helps make it clear. I need to be able to show code examples as my tutorials are for web design does anyone know a way of showing code. I can disable the tinycme editor and type code right into the textfeild and use the html safe values like: <?php echo date ('Y'); ?> but thats not a good solution as i want to use the tinymce editor as my members will be able to write some tutorials any help would be great Thanks Quote Link to comment Share on other sites More sharing options...
frost Posted August 21, 2007 Share Posted August 21, 2007 I am not sure if this will help but I had a similar problem - http://www.phpfreaks.com/forums/index.php/topic,155966.0.html Quote Link to comment Share on other sites More sharing options...
nuttycoder Posted August 21, 2007 Author Share Posted August 21, 2007 with that example would you type in the code and / code in brackets and what ever is show inbetween them will show as there meant to be seen? Quote Link to comment Share on other sites More sharing options...
nuttycoder Posted August 21, 2007 Author Share Posted August 21, 2007 the code is still removed i think its the tinymce editor i may have to look at other editors to use know any good ones? Quote Link to comment Share on other sites More sharing options...
frost Posted August 21, 2007 Share Posted August 21, 2007 Using the example I showed you would let you post whatever you like in tinymce, just use the example when displaying the code. Quote Link to comment Share on other sites More sharing options...
nuttycoder Posted August 21, 2007 Author Share Posted August 21, 2007 got it working i can post code and it shows. I had to disable the tinymce editor for it to work, so i'll either hve to find a way round it with thi editor or find another. Thanks btw even without the editor in place i can post code save it and then view it on the page showing the tutorial only when i go to edit the information again i have to type in code and /code each time it seems to get stripped any idea why? I can see code and /code inthe db using phpmyadmin but its not there when i go to edit the tutorial using my php script Quote Link to comment Share on other sites More sharing options...
frost Posted August 22, 2007 Share Posted August 22, 2007 Can you post the code you are using to display your stuff? Quote Link to comment Share on other sites More sharing options...
keeB Posted August 22, 2007 Share Posted August 22, 2007 You're going to need to use < , > , etc. Instead of doing it manually, though, you can have a function such a str_replace (http://php.net/str_replace) do it for you. Quote Link to comment Share on other sites More sharing options...
nuttycoder Posted August 22, 2007 Author Share Posted August 22, 2007 Been experimenting with diffrent settings on the tinymce and if I turn the editor into basic mode I can post code and it shows up turning all code typed into the html safe version and also able to have the normal html tags <p>,< b>..ect using the editor which is exacly what i need. Thanks for everyone who's helped me with this at the very least I've learn't useful ways of using htmlspecialchars & expressions, While learing something new its never been a wasted time Thanks again. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.