Page 1 of 1

forum error!

Posted: Wed Dec 03, 2003 8:50 pm
by dull1554
this is my script

add_topic.php

Code: Select all

<?php
if((!isset($_POST['subject'])) or (!isset($_POST['body'])))
{
     echo 'You must enter <b>ALL</b> fields before you can continue!';
     exit;
}
else{
$subject = $_POST['subject'];
$username = $_COOKIE['complexscriptinguser'];
$area = $_POST['area'];
$body = $_POST['body'];
$time =   date("D d of F, h:i a");



if($area == "php")
{

$oldtopics = implode('',file("topics_php.txt"));

$fp = fopen("topics_php.txt", "w");
$insertcode = "<a href=".$subject.".txt>"$subject"</a>";
fwrite($fp, $insertcode);
fwrite($fp,$oldnews);
fclose($fp);

$crt = fopen($subject.".txt", "w");
$insertcode = "<table width='100%' border='0' cellspacing='1' cellpadding='2' bgcolor='#dcdcdc' align='center'>
<tr><td width='100%' border='1' bgcolor='whitesmoke'>".$subject." - ".$time."</td>
<td width='100%' border='1' bgcolor='whitesmoke'>
Posted by: ".$username"</td></tr><tr><td width='100%' border='1' bgcolor='#ffffff'>".$body."</td></tr></table>";
fwrite($crt, $insertcode);
fwrite($crt,$oldnews);
fclose($crt);
}


if($area == "html")
{
$oldtopics = implode('',file("topics_html.txt"));

$fp = fopen("topics_html.txt", "w");
$insertcode = "<a href=".$subject.".txt>"$subject"</a>";
fwrite($fp, $insertcode);
fwrite($fp,$oldnews);
fclose($fp);

$crt = fopen($subject.".txt", "w");
$insertcode = "<table width='100%' border='0' cellspacing='1' cellpadding='2' bgcolor='#dcdcdc' align='center'>
<tr><td width='100%' border='1' bgcolor='whitesmoke'>".$subject." - ".$time."</td>
<td width='100%' border='1' bgcolor='whitesmoke'>
Posted by: ".$username"</td></tr><tr><td width='100%' border='1' bgcolor='#ffffff'>".$body."</td></tr></table>";
fwrite($crt, $insertcode);
fwrite($crt,$oldnews);
fclose($crt);
}


if($area == "css")
{
$oldtopics = implode('',file("topics_css.txt"));

$fp = fopen("topics_css.txt", "w");
$insertcode = "<a href=".$subject.".txt>"$subject"</a>";
fwrite($fp, $insertcode);
fwrite($fp,$oldnews);
fclose($fp);

$crt = fopen($subject.".txt", "w");
$insertcode = "<table width='100%' border='0' cellspacing='1' cellpadding='2' bgcolor='#dcdcdc' align='center'>
<tr><td width='100%' border='1' bgcolor='whitesmoke'>".$subject." - ".$time."</td>
<td width='100%' border='1' bgcolor='whitesmoke'>
Posted by: ".$username"</td></tr><tr><td width='100%' border='1' bgcolor='#ffffff'>".$body."</td></tr></table>";
fwrite($crt, $insertcode);
fwrite($crt,$oldnews);
fclose($crt);
}


if($area == "js")
{
$oldtopics = implode('',file("topics_js.txt"));

$fp = fopen("topics_js.txt", "w");
$insertcode = "<a href=".$subject.".txt>"$subject"</a>";
fwrite($fp, $insertcode);
fwrite($fp,$oldnews);
fclose($fp);

$crt = fopen($subject.".txt", "w");
$insertcode = "<table width='100%' border='0' cellspacing='1' cellpadding='2' bgcolor='#dcdcdc' align='center'>
<tr><td width='100%' border='1' bgcolor='whitesmoke'>".$subject." - ".$time."</td>
<td width='100%' border='1' bgcolor='whitesmoke'>
Posted by: ".$username"</td></tr><tr><td width='100%' border='1' bgcolor='#ffffff'>".$body."</td></tr></table>";
fwrite($crt, $insertcode);
fwrite($crt,$oldnews);
fclose($crt);
}


if($area == "perl")
{
$oldtopics = implode('',file("topics_perl.txt"));

$fp = fopen("topics_perl.txt", "w");
$insertcode = "<a href=".$subject.".txt>"$subject"</a>";
fwrite($fp, $insertcode);
fwrite($fp,$oldnews);
fclose($fp);

$crt = fopen($subject.".txt", "w");
$insertcode = "<table width='100%' border='0' cellspacing='1' cellpadding='2' bgcolor='#dcdcdc' align='center'>
<tr><td width='100%' border='1' bgcolor='whitesmoke'>".$subject." - ".$time."</td>
<td width='100%' border='1' bgcolor='whitesmoke'>
Posted by: ".$username"</td></tr><tr><td width='100%' border='1' bgcolor='#ffffff'>".$body."</td></tr></table>";
fwrite($crt, $insertcode);
fwrite($crt,$oldnews);
fclose($crt);
}


if($area == "asp")
{
$oldtopics = implode('',file("topics_asp.txt"));

$fp = fopen("topics_asp.txt", "w");
$insertcode = "<a href=".$subject.".txt>"$subject"</a>";
fwrite($fp, $insertcode);
fwrite($fp,$oldnews);
fclose($fp);

$crt = fopen($subject.".txt", "w");
$insertcode = "<table width='100%' border='0' cellspacing='1' cellpadding='2' bgcolor='#dcdcdc' align='center'>
<tr><td width='100%' border='1' bgcolor='whitesmoke'>".$subject." - ".$time."</td>
<td width='100%' border='1' bgcolor='whitesmoke'>
Posted by: ".$username"</td></tr><tr><td width='100%' border='1' bgcolor='#ffffff'>".$body."</td></tr></table>";
fwrite($crt, $insertcode);
fwrite($crt,$oldnews);
fclose($crt);
}


if($area == "sql")
{
$oldtopics = implode('',file("topics_sql.txt"));

$fp = fopen("topics_sql.txt", "w");
$insertcode = "<a href=".$subject.".txt>"$subject"</a>";
fwrite($fp, $insertcode);
fwrite($fp,$oldnews);
fclose($fp);

$crt = fopen($subject.".txt", "w");
$insertcode = "<table width='100%' border='0' cellspacing='1' cellpadding='2' bgcolor='#dcdcdc' align='center'>
<tr><td width='100%' border='1' bgcolor='whitesmoke'>".$subject." - ".$time."</td>
<td width='100%' border='1' bgcolor='whitesmoke'>
Posted by: ".$username"</td></tr><tr><td width='100%' border='1' bgcolor='#ffffff'>".$body."</td></tr></table>";
fwrite($crt, $insertcode);
fwrite($crt,$oldnews);
fclose($crt);
}
}
?>
heres my error

Code: Select all

Parse error: parse error, unexpected T_VARIABLE in c:\program files\apache group\apache\htdocs\forum\add_topic.php on line 22

Posted: Wed Dec 03, 2003 9:05 pm
by microthick
$insertcode = "<a href=".$subject.".txt>"$subject"</a>";

Is this line 22? Missing a couple periods around the 2nd $subject?

Posted: Wed Dec 03, 2003 9:05 pm
by dull1554
i found my mistakes, i'm sorry fo the inconvience, i forgot to concate in a few places!

Posted: Wed Dec 03, 2003 9:07 pm
by uberpolak
Here's your problem

Code: Select all

<?php
$insertcode = "<a href=".$subject.".txt>"$subject"</a>";
?>
Change it to one of these:

Code: Select all

<?php

$insertcode = "<a href="$subject.txt">$subject</a>";

$insertcode = '<a href="'.$subject.'.txt">'.$subject.'</a>';

?>
Personally, I would go with the second one. I only looked at the line you specified, you may have the same error elsewhere, so check for it if you get that message again.

Posted: Wed Dec 03, 2003 9:23 pm
by dull1554
thanks everyone, i love this place

Posted: Wed Dec 03, 2003 10:00 pm
by Nay
*puts on a heredoc suit and smashes into you*

-Nay

Posted: Thu Dec 04, 2003 2:48 pm
by dull1554
*falls to the floor in pain*
*quivers*
*rejoices, for dull1554 loves heredoc*
^%#@*&^%()**