forum error!

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
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

forum error!

Post 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
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

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

Is this line 22? Missing a couple periods around the 2nd $subject?
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

i found my mistakes, i'm sorry fo the inconvience, i forgot to concate in a few places!
User avatar
uberpolak
Forum Contributor
Posts: 261
Joined: Thu Jan 02, 2003 10:37 am
Location: Next to the bar

Post 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.
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

thanks everyone, i love this place
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

*puts on a heredoc suit and smashes into you*

-Nay
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

*falls to the floor in pain*
*quivers*
*rejoices, for dull1554 loves heredoc*
^%#@*&^%()**
Post Reply