[quote] [/quote]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

[quote] [/quote]

Post by Jim_Bo »

Hey,

How is the [quote]

Code: Select all

etc systems setup within forums?

A starting point or understanding how its done ..


Thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

research 'bbtags' or 'bbcode' ... it's been talked about a lot in the last few days. Evilwalrus has a few quick and dirty implementations of bbcode..
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post by smpdawg »

I think this thread is very similar to what you are asking.

viewtopic.php?t=30734
Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

Post by Jim_Bo »

Hi,

At the expense of looking like an idiot ..

Is it ment to be implimented like so:

read.php = This is the page where the message whole is read ..

Code: Select all

$sql = mysql_query("SELECT sender, subject, message FROM pm WHERE id=$id") or die (mysql_error()); 

while ($row = mysql_fetch_array($sql)) { 
    $sender = $rowї"sender"]; 
    $subject = $rowї"subject"];

    $message = eregi_replace('\&#1111;quote]', '<b>Quote:</b><blockquote style="width: 100%; margin: 3px 8px 3px 16px; color: #000; background-color: #333; border: 2px solid #808080; font-size: 8pt;">', $message); 
    $message = eregi_replace('\&#1111;/quote]', '</blockquote>', $message);
Is it ment to look something like this .. [quote]data between[//quote]

It then writes it into the quote format ..

P.S It doesnt work :oops:


Thanks
Last edited by Jim_Bo on Sun Feb 20, 2005 5:12 pm, edited 1 time in total.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

you are not passing the correct variable to eregi_replace

might want to take a look at http://php.net/eregi_replace

it looks something like $message = eregi_replace( pattern, replace, source );
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

$message wasn't set previously. The first replace should use $row['message'] as the source argument.


I'd advise switching to preg_* instead of ereg_*
Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

Post by Jim_Bo »

Hi,

Am I even on the right track ..

There is code in the database:

[quote]Test quote code[//quote] did it work?

without the double // in the 2nd quote ..

I call it back in the read.php page like so:

Code: Select all

$sql = mysql_query("SELECT sender, subject, message FROM pm WHERE id=$id") or die (mysql_error()); 

while ($row = mysql_fetch_array($sql)) &#123; 
    $sender = $row&#1111;"sender"]; 
    $subject = $row&#1111;"subject"];
	
    $message = ereg_replace('\&#1111;quote]', '<b>Quote:</b><blockquote style="width: 100%; margin: 3px 8px 3px 16px; color: #000; background-color: #333; border: 2px solid #808080; font-size: 8pt;">', $row&#1111;'message']); 
    $message = ereg_replace('\&#1111;/quote]', '</blockquote>', $row&#1111;'message']);
When I view the read.php page the message format still reads like so:

[quote]Test quote code[//quote] did it work?

Am I even on the right track with the way its been called back out of the database into the read.php page?

Thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

first off I said to use preg, not ereg.
second, I said only the first replace call needs to use $row['message'] as the source. The second still should use $message.. although I'm not a fan of processing the in and out seperately, but rather as a single unit.

How are you printing out the data?
Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

Post by Jim_Bo »

Hi,

I tried preg but got errors .. so I was gunna get it working and get an understanding of how it all works b4 trying to figure out preg_

Its being printed using <?php echo $row["message"]; ?> between html ..


Thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

that's why it's not showing any changes.. echo $message.
Post Reply