
August 4th, 2003, 02:46 PM
|
|
Junior Member
|
|
Join Date: Aug 2003
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Coding problem
Hi:
On my site, I'm creating a tutorials system. I have this set of code, where after I submit from a textarea, right before I insert the data into a database, I use some ubb code. I say, the text surrounding: [table], [/table], should be replaced by the text in highlight_string($text); Here's the problem. In my code, the textarea name is $msg. I do this: $msg = nl2br($msg); But, within the [table], if I press enter, to do some PHP code, it shows the code, plus, it shows the <br />, as well as it skips the lines. I want it so that it shows no <br />, just skips the lines. My code is below:
PHP Code:
<?php
if(!$submit) {
echo "<form method=\"POST\" action=\"$PHP_SELF\">
<textarea name=\"msg\" cols=\"25\" rows=\"10\"></textarea>
<input type=\"submit\" name=\"submit\" value=\"submit\">";
} else if($submit && !empty($msg)) {
$msg = nl2br($msg);
$msg = stripslashes($msg);
preg_match_all("/\[table\](.*?)\[\/table\]/si",$msg, $out, PREG_PATTERN_ORDER);
for($i=0;$i<count($out[0]);$i++)
{
$msg=str_replace($out[0][$i], "<table bgcolor=\"#cccc99\" cellpadding=\"3\" cellspacing=\"0\" border=\"1\"><tr><td>".highlight_string($out[1][$i], true)."</td></tr></table>", $msg);
}
echo $msg;
}
?>
Thanks for all the help you may give to me on this topic!!
Ken Cooper
|