lilwing Posted August 16, 2007 Share Posted August 16, 2007 hey guys, i am stuck. i have a place for people to post with bbcode (written with javascript), the data is posted and sent to a mysql database, and retrieved from my website's page, where it is displayed. when the data shows up on the page, the bbcode is still visible. is there a php script for this? if there is where would i put it? on the website's page? Quote Link to comment https://forums.phpfreaks.com/topic/65263-solved-replacing-bbcode-with-html-tags-using-php/ Share on other sites More sharing options...
NArc0t1c Posted August 16, 2007 Share Posted August 16, 2007 There are many script's out there to do this. It's actually very simple to make it. Example to take [ b] to < b>. <?php function bbcode($String){ if (empty($string)){ return false; } $String = srt_replace("[b]","<b>",$String); return $String; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/65263-solved-replacing-bbcode-with-html-tags-using-php/#findComment-325892 Share on other sites More sharing options...
MadTechie Posted August 16, 2007 Share Posted August 16, 2007 Ahhh BBCODE messed it up Quote Link to comment https://forums.phpfreaks.com/topic/65263-solved-replacing-bbcode-with-html-tags-using-php/#findComment-325894 Share on other sites More sharing options...
MadTechie Posted August 16, 2007 Share Posted August 16, 2007 See attached text file [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/65263-solved-replacing-bbcode-with-html-tags-using-php/#findComment-325897 Share on other sites More sharing options...
NArc0t1c Posted August 16, 2007 Share Posted August 16, 2007 Like my example, I just didn't want to type all of that. Quote Link to comment https://forums.phpfreaks.com/topic/65263-solved-replacing-bbcode-with-html-tags-using-php/#findComment-325899 Share on other sites More sharing options...
MadTechie Posted August 16, 2007 Share Posted August 16, 2007 indeed already had the code written Quote Link to comment https://forums.phpfreaks.com/topic/65263-solved-replacing-bbcode-with-html-tags-using-php/#findComment-325900 Share on other sites More sharing options...
lilwing Posted August 16, 2007 Author Share Posted August 16, 2007 it's not working. i probably did something wrong. for example: function bbcode($String){ if (empty($string)){ return false; } $String = srt_replace("[b]","<b>",$String); return $String; } $host="localhost"; // Host name $username="bleep"; // Mysql username $password="bleep"; // Mysql password $db_name="bleep"; // Database name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql = "SELECT * FROM headlines ORDER BY id DESC LIMIT 2"; $query = mysql_query($sql); while($row = mysql_fetch_array($query)) { $current = $row['pagecontent']; bbcode($current); echo $current; } Quote Link to comment https://forums.phpfreaks.com/topic/65263-solved-replacing-bbcode-with-html-tags-using-php/#findComment-325901 Share on other sites More sharing options...
lilwing Posted August 16, 2007 Author Share Posted August 16, 2007 bump Quote Link to comment https://forums.phpfreaks.com/topic/65263-solved-replacing-bbcode-with-html-tags-using-php/#findComment-325926 Share on other sites More sharing options...
MadTechie Posted August 16, 2007 Share Posted August 16, 2007 $current = $row['pagecontent']; $current = bbcode($current); //Here echo $current; why not use the code i posted :'( Quote Link to comment https://forums.phpfreaks.com/topic/65263-solved-replacing-bbcode-with-html-tags-using-php/#findComment-325938 Share on other sites More sharing options...
lilwing Posted August 16, 2007 Author Share Posted August 16, 2007 edit: whoohoo! got it working now. thanks! Quote Link to comment https://forums.phpfreaks.com/topic/65263-solved-replacing-bbcode-with-html-tags-using-php/#findComment-325967 Share on other sites More sharing options...
NArc0t1c Posted August 16, 2007 Share Posted August 16, 2007 $current = $row['pagecontent']; $current = bbcode($current); //Here echo $current; why not use the code i posted :'( Quote Link to comment https://forums.phpfreaks.com/topic/65263-solved-replacing-bbcode-with-html-tags-using-php/#findComment-326005 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.