Jump to content

Forum Help


twsowerby

Recommended Posts

I won't be of much more help today... gotta get onto other things.

 

Keep some rules in mind:

 

1. Never echo out HTML until you have everything you need to do so. Although it doesn't seem apparent, this will become a big issue later. So, don't echo some HTML, then do some PHP, then some more HTML, etc... Anything done with PHP should be stored in variables when possible, then, once we are sure a page is ready to go out, we echo out the header, the content, then the footer.

 

2. Whenever you send out a page, it goes:

<?php
include "header.php";

// echo your content

include "footer.php";

 

3. In order to utilize this in any of the other scripts, add define('IN_FORUM', true); to the top of said script, or you will be tossed back to index.php.

 

4. Repeat... keep all code separate from HTML, and keep the code at the top of the page when possible. Please replace all instances of 'print' with 'echo'. It's what we more or less prefer to use, and it's ingrained habit. I'll go crazy trying to remember to use print every time! heh

 

Ok, I'll be back after I get some work done on this form I have promised to another user... he's been rather patient.

 

PhREEEk

Link to comment
Share on other sites

Ok I'm trying to implement this bbcode into the forum and I can't really get it to work.

 

Code is:

 

//BBcode Funtions

function bb_format ($str) {
$str = htmlentities($str);

$bold_italic_underline_url_search = array (
		'/\[b\](.*?)\[\/b\]/is',                               
            '/\[i\](.*?)\[\/i\]/is',                               
            '/\[u\](.*?)\[\/u\]/is',
		'/\[url\=(.*?)\](.*?)\[\/url\]/is'
		);

$bold_italic_underline_url_replace = array (
		'<strong>$1</strong>',
            '<em>$1</em>',
            '<u>$1</u>',
		'<a href="$1">$2</a>'
            );

$str = preg_replace ($bold_italic_underline_search, $bold_italic_underline_replace, $str);

return $str;
}

 

I've got it sat in my functions.php file but when I call it it doesnt seem to be working. To be honest I dont really understand the way the code works so any pointers would be great.

 

I know the basic concept is to take the tags inserted by the person writing the post and swap them with the proper html tags, but im not sure how to go about making it work.

 

Cheers,

 

Tom

Link to comment
Share on other sites

Not really sure how I'm meant to call it, so I tried this:

 

<?php 

// File: message.php
//

define('IN_FORUM', true);
include_once "sqlconnect.php";
include_once "includes/functions.php";

include "includes/header.php";


$id=$_GET['id'];

echo "<link rel='stylesheet' href='style.css' type='text/css'>";

echo "<a href='index.php'>Back to main forum</a>-<A href='post.php'>New Topic</a>-<a href='reply.php?id=$id'>Reply<br>";

echo "<table class='maintable'>";

echo "<tr class='headline'><td width=20%>Author</td><td width=80%>Post</td></tr>";

$gettopic="SELECT * from forum_posts where postid='$id'";

$gettopic2=mysql_query($gettopic) or die("Could not get topic");

$gettopic3=mysql_fetch_array($gettopic2);

echo "<tr class='mainrow'><td valign='top'>$gettopic3[author]</td><td valign='top'>Last replied to at $gettopic3[showtime]<br><hr>";

$message=strip_tags($gettopic3['post']);

$message=nl2br($message);

echo "$message<hr><br>";

echo "</td></tr>";

$getreplies="select * from forum_posts where parentid='$id' order by postid desc"; //getting replies

$getreplies2=mysql_query($getreplies) or die("Could not get replies");

while($getreplies3=mysql_fetch_array($getreplies2))

{

   bb_format (echo "<tr class='mainrow'><td valign='top'>$getreplies3[author]</td><td valign='top'>Last replied to at $getreplies3[showtime]<br><hr>"

   $message=strip_tags($getreplies3['post']);

   $message=nl2br($message);

   echo "$message<hr><br>";

   echo "</td></tr>";

}

echo "</table>";



include "includes/footer.php";

?>

 

The bb_format (echo "<tr class='mainrow'><td valign='top'>$getreplies3[author]</td><td valign='top'>Last replied to at $getreplies3[showtime]<br><hr>";) part is where i think it should go...

 

Tom

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.