ngreenwood6 Posted November 3, 2008 Share Posted November 3, 2008 I am trying to create a section on my website where users can submit php code. I am trying to get the code into the database and have it pull it back up later but I want the code section to be in a code like section. Does anyone know how I can accomplish this. I tried adding [c0de] and [/c0de] but it just parses it and shows the "[c0de]" when it is pulled from the database. Any help is appreciated. Also can somebody tell me how to make it so that when a post is made that it will post it just how it was written. For example to make it read like a word document. Quote Link to comment https://forums.phpfreaks.com/topic/131199-solved-code-tags/ Share on other sites More sharing options...
gaza165 Posted November 3, 2008 Share Posted November 3, 2008 I have been doing a similar thing on my forum. http://forum.thedesignmonkeys.co.uk If you use highlight_string($string) the code will be coloured just like it is in this forum.. just like this <?php echo "hello this is php code"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/131199-solved-code-tags/#findComment-681160 Share on other sites More sharing options...
ngreenwood6 Posted November 3, 2008 Author Share Posted November 3, 2008 Thanks for the response but can you tell me how I would implement that into a text box for entry into the database. Quote Link to comment https://forums.phpfreaks.com/topic/131199-solved-code-tags/#findComment-681162 Share on other sites More sharing options...
gaza165 Posted November 3, 2008 Share Posted November 3, 2008 Well the way to do it is when you pull it back from the database to use the highlight_string function on the text you want to highlight which is PHP. are you encasing php code in or [ code ] tags???? Quote Link to comment https://forums.phpfreaks.com/topic/131199-solved-code-tags/#findComment-681167 Share on other sites More sharing options...
ngreenwood6 Posted November 3, 2008 Author Share Posted November 3, 2008 Well that is what I am trying to figure out. I am trying to set it up so that a user can make a post and they can use plain text and then the can select something like a code tag and it wrap everything in the code tag and store all the information in the database for further use. I having a problem trying to figure out how to get it to store the information and only apply the formatting to a certain part which is in the code tag. Any help is appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/131199-solved-code-tags/#findComment-681314 Share on other sites More sharing options...
ngreenwood6 Posted November 3, 2008 Author Share Posted November 3, 2008 BUMP... I am sure that someone knows how to do this or can get me started in the right direction. Quote Link to comment https://forums.phpfreaks.com/topic/131199-solved-code-tags/#findComment-681351 Share on other sites More sharing options...
laffin Posted November 3, 2008 Share Posted November 3, 2008 U grab stuff between the & tags (preg_match) apply the hightlighting apply codes that wont interfere with the bbcode/smilie parser reinsert this block back into the message the message can be stored in its bbcoded state. for special codes ya can look here Special HTML Codes by replacing the '[' with the special code, ya avoid the bbcode parser alltogether, than it comes to any smilies that may be in the code. Quote Link to comment https://forums.phpfreaks.com/topic/131199-solved-code-tags/#findComment-681393 Share on other sites More sharing options...
ngreenwood6 Posted November 3, 2008 Author Share Posted November 3, 2008 Can you elaborate a little bit better on how to do this? Sorry I am kinda a noob. I can get around the basics but need a little explaining for new features. I used [c0de] with the 0 so that I could type that out. Quote Link to comment https://forums.phpfreaks.com/topic/131199-solved-code-tags/#findComment-681399 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.