I made a bbcode function for my news system, I wanted to add a php tag and so I tried but it didn't work, here is my code: [code]<? function bbcode($content){ $content = nl2br(htmlspecialchars($content)); $bbcode = array( "'\[b\](.*?)\[/b\]'", "'\[i\](.*?)\[/i\]'", "'\[u\](.*?)\[/u\]'", "'\[code\](.+?)\[/code\]'", "'\[url=(.*?)\](.*?)\[/url\]'", "'\[url\](.*?)\[/url\]'", "'\[img\](.*?)\[/img\]'", "'\[php\](.*?)\[/php\]'" ); $html = array( "<b>\\1</b>", "<i>\\1</i>", "<u>\\1</u>", "<strong>Code:</strong><div style=\"margin:0px 10px;padding:5px;border:1px dotted #FFFFFF;width:80%;\"></em>\\1</em></div>", "<a href=\"\\1\" target=\"_BLANK\">\\2</a>", "<a href=\"\\1\" target=\"_BLANK\">\\1</a>", "<img border=\"0\" src=\"\\1\">", "<strong>PHP:</strong><div style=\"margin:0px 10px;padding:5px;border:1px dotted #FFFFFF;width:80%;\"></em><?php highlight_sting(\"\\1\"); ?></em></div> ); $content = preg_replace($bbcode, $html, $content); return nl2br($content); } ?>[/code] Oh also my news comments aren't showing up (I get the header and menu but no content) here is my code: [code]<?php ob_start(); // allows us to use cookies include("config.php"); // includes the config file if ($logged['username']){ // if the user is logged in they can view this switch($_GET['view']){ // news_comments.php?view= case 'news': // news_comments.php?view=news&id=$id $id = $_GET['acl']; // grabs the requested id $select = "select * from news where id=$id"; // selects the requested id from the database $select2 = "select * from news_comments where nid=$id ORDER BY id DESC"; // grabs comments for the news article $getnews = mysql_query($select) // querys the news db or die(mysql_error()); // die error! $getcomments = mysql_query($select2); // querys the comments db if (mysql_num_rows($getnews) == "0") { // if we are returned a nulled result echo 'Unable to find the article in our database'; // nothing found error! exit(); // exit } $row = mysql_fetch_array($getnews) // array or die(mysql_error()); // error! $nid = $row['id']; // news id $ntitle = $row['title']; // news title $ncontent = bbcode($row['content']); // news content with bbcode wrapped around it $nauthor = $row['author']; // news author $postdate = $row['postdate']; // news date echo ("<tr> <td>$ntitle Posted by <a href=\"index.php?id=memb&user=$nauthor\">$nauthor</a> At $postdate<br></td> </tr> <tr> <td>$ncontent<br><br>Comments:<br></td> </tr>"); if (mysql_num_rows($getcomments) == "0") { // if we are returned a nulled result for the comments echo a link to add em echo("There are no comments!<br>[<a href=\"index.php?id=newscom&view=addcomment&acl=$id\">Add a comment</a>]"); // add a link! } if($logged[username] && $logged[level] ==5) // if the user is a admin while($rowc= mysql_fetch_array($getcomments)){ // fetches an array $cauthor = $rowc['author']; // comment author $ccomment = bbcode($rowc['content']); // comment content $cdate = $rowc['postdate']; // comment date echo ("<tr> <td>Comment Posted by <a href=\"index.php?id=memb&user=$nauthor\">$cauthor</a> At $cdate [<a href=\"index.php?id=newad&view=editcomment&acl=$id\">Edit</a>] [<a href=\"index.php?id=newad&view=deletecomment&acl=$id\">Delete</a>]<br></td> </tr> <tr> <td>$ccomment<br><br></td> </tr>"); } while($rowc= mysql_fetch_array($getcomments)){ // if the user is a normal user echo this $cauthor = $rowc['author']; // comment author $ccomment = bbcode($rowc['content']); // comment content $cdate = $rowc['postdate']; // comment date echo ("<tr> <td>Comment Posted by <a href=\"index.php?id=memb&user=$nauthor\">$cauthor</a> At $cdate<br></td> </tr> <tr> <td>$ccomment<br><br></td> </tr>"); } echo("[<a href=\"index.php?id=newscom&view=addcomment&acl=$id\">Add a comment</a>]"); // add a comment break; case 'addcomment': // page for adding comments news_comments.php?view=addcomment&id=&id ob_start(); // cookies include("config.php"); // includes the config file $id = $_GET['acl']; // grabs the news id if(isset($_POST['add_comment'])) { // if the form has been submitted we query the db $author = $logged['username']; // comments author $postdate = date("g:i A, l F j"); // comments date $content = $_POST[content]; // comment $nid = $_GET['acl']; // news id $sql = "INSERT INTO news_comments ( `author` , `postdate`, `content`, `nid`) VALUES ('$author', '$postdate', '$comment', '$nid')"; // query for adding the comment $addblog = mysql_query($sql) // query?s the db or die(mysql_error()); // error! header("Location: index.php"); // redirects the user } else // the form has not been submitted so we display it { echo ("<form method=\"post\" name=\"addcomment\"> <tr> <td height=\"20\">Comment:</td> </tr> <tr> <td><br><textarea rows=\"5\" cols=\"35\" name=\"content\">Type your comment here!</textarea><br> <input type=\"submit\" name=\"add_comment\" value=\"Submit\"></td> </tr> </form>"); } } if (!isset($_GET['id'])) // if there is not requested id we redirect the user header("Location:index.php?id=news"); // goto news.php }else{ echo('Hey! you need to [<a href=http://vexxon.net/login.php>login</a>] first!'); // user is not logged in so they are asked to.'); } ?>[/code] And my link system is not working either, here is the code for it: [code] <?php ob_start(); // allows us to use cookies include("config.php"); // includes the config file if(!$logged[username]) { header("Location:http://vexxon.net"); // if they arent logged in or dont have admin powers they are redirected } function cleanlink($url) { $filter = array( "http://" => "", "www." => "", ); foreach ($filter as $remove => $stay) { $url = str_replace($remove, $stay, $url); } $filterurl = explode("/", $url); $bombedurl = $filterurl[0]; $url = "http://"; $url .= "$bombedurl"; $url .= "/"; return $url; } if(isset($_POST['submit'])) { $title=$_POST['title']; $url= cleanlink($_POST['url']); $description=$_POST['description']; $sql = mysql_query("INSERT INTO `links` ( `title` , `url` , `description` ) VALUES ('$title', '$url', '$description');"); // adds the link to the db header("Location:http://www.vexxon.net/index.php?id=links"); } else { ?> <form method="post" name="links"> <table width="52%" height="459" border="0"> <tr> <td valign="top">Links Title: </td> <td valign="top"><input name="title" type="text"></td> </tr> <tr> <td valign="top">Links URL: </td> <td valign="top"><input name="url" type="text" value="http://"></td> </tr> <tr> <td height="85" valign="top">Description: <br> </td> <td valign="top"><textarea cols="50" rows="20" name="description"></textarea> </td> </tr> <tr> <td height="25" valign="top"> </td> <td valign="top"><input type="submit" name="submit" value="Submit Link"></td> </tr> </table> </form> <? } ?>[/code]