Jump to content
xisto Community
Sign in to follow this  
shadowdemon

Another Parse Error lol

Recommended Posts

<?php $title = "Forums"; include("header.php"); ?><?php// the Topic Listif ($view == topics) {	print "<table><tr><td width=150><u><b>Topic</td><td width=100><u><b>Starter</td><td width=50><b><u>Replies</td></tr>";	$tsel = mysql_query("select * from topics2");	while ($topic = mysql_fetch_array($tsel)) {		$replies = mysql_num_rows(mysql_query("select * from replies2 where topic_id=$topic[id]"));		if ($sticky == yes){print "<tr><td><a href=forums.php?topic=$topic[id]>$topic[topic]</a></td><td>$topic[starter]</td><td>$replies</td></tr>";}		print "<tr><td><a href=forums.php?topic=$topic[id]>$topic[topic]</a></td><td>$topic[starter]</td><td>$replies</td></tr>";	}	print "</table>";	print "</center><form method=post action=forums2.php?action=addtopic>";	print "Add Topic:<br><input type=text name=title2 value=Title><br><textarea name=body cols=30 rows=3>Body</textarea><br><input type=submit value=\"Add Topic\"></form>";}// View Topicif ($topic) {	$topicinfo = mysql_fetch_array(mysql_query("select * from topics2 where id=$topic"));	if (empty ($topicinfo[id])) {		print "No such topic.";		include("footer2.php");		exit;	}		if ($stat[rank] == 'admin'){		echo "<a href="forums2.php?action=sticky">sticky the topic</a>";}		if ($action == sticky){mysql_query("Update topics2 set sticky=yes where topic_id=$topic[id]");		echo "<a href="forums2.php?view=topics">back</a>">}=view	print "<center><br><table class=td width=98% cellpadding=0 cellspacing=0><tr><td style=\"border-bottom: solid black 1px;\" bgcolor=eeeeee><b>$topicinfo[topic]</b> by $topicinfo[starter] (<a href=forums2.php?view=topics>back</a>)</td></tr>";	print "<tr><td>$topicinfo[body]</td></tr></table><br>";		$rsel = mysql_query("select * from replies2 topic_id=$topicinfo[id] order by id asc");	while ($reply = mysql_fetch_array($rsel)) {		print "<center><table class=td width=98% cellpadding=0 cellspacing=0><tr><td bgcolor=eeeeee style=\"border-bottom: solid black 1px;\"><b>$reply[starter]</b> says... (<a href=forums2.php?view=topics>back</a>)</td></tr>";		print "<tr><td>$reply[body]</td></tr></table><br>";	}	print "</center><form method=post action=forums.php?reply=$topicinfo[id]>";	print "Add Reply:<br><textarea name=rep cols=30 rows=3>Body</textarea><br><input type=submit value=\"Add Reply\"></form>";}// Add Topicif ($action == addtopic) {	if (empty ($title) || empty ($body)) {		print "You must fill all fields.";		include("footer2.php");		exit;	}	mysql_query("insert into topics2 (topic, body, starter) values('$title2', '$body', '$stat[user]')") or die("Could not add topic.");	print "Added topic. Click <a href=forums2.php?view=topics>here</a> to go back to the topic list.";}// Add Replyif ($reply) {$exists = mysql_num_rows(mysql_query("select * from topics2 where id=$reply"));	if ($exists <= 0) {		print "No such topic.";		include("footer2.php");		exit;	}	if (empty ($rep)) {		print "You must fill out all fields.";		include("footer2.php");		exit;	}mysql_query("insert into replies2 (starter, topic_id, body) values('$stat[user]', $reply, '$rep')") or die("Could not add reply.");print "Reply added. Click <a href=forums2.php?topic=$reply>here</a>.";}?><?phpinclude("footer.php");?>

Parse error: parse error, expecting `','' or `';'' in /home/www/dancha42.madpage.com/forums2.php on line 35

hopefully i wont have many moreim starting to learn to find them better, but i dont understand this parse error

Share this post


Link to post
Share on other sites

oh ty now i no what i deleted. I say something and didnt no what it was so i deleted it so ill try that and everyone elses

edit

this is the new code

<?php $title = "Forums"; include("header.php"); ?><?php// the Topic Listif ($view == topics) {	print "<table><tr><td width=150><u><b>Topic</td><td width=100><u><b>Starter</td><td width=50><b><u>Replies</td></tr>";	$tsel = mysql_query("select * from topics2");	while ($topic = mysql_fetch_array($tsel)) {		$replies = mysql_num_rows(mysql_query("select * from replies2 where topic_id=$topic[id]"));		if ($sticky == yes){print "<tr><td><a href=forums2.php?topic=$topic[id]>$topic[topic]</a></td><td>$topic[starter]</td><td>$replies</td></tr>";}		print "<tr><td><a href=forums2.php?topic=$topic[id]>$topic[topic]</a></td><td>$topic[starter]</td><td>$replies</td></tr>";	}	print "</table>";	print "</center><form method=post action=forums2.php?action=addtopic>";	print "Add Topic:<br><input type=text name=title2 value=Title><br><textarea name=body cols=30 rows=3>Body</textarea><br><input type=submit value=\"Add Topic\"></form>";}// View Topicif ($topic) {	$topicinfo = mysql_fetch_array(mysql_query("select * from topics2 where id=$topic"));	if (empty ($topicinfo[id])) {		print "No such topic.";		include("footer2.php");		exit;	}	  if ($stat[rank] == 'admin'){		echo "<a href="forums2.php?action=sticky">sticky the topic</a>";}	  if ($action == sticky){mysql_query("Update topics2 set sticky=yes where topic_id=$topic[id]");		echo "<a href="forums2.php?view=topics">back</a>";}	print "<center><br><table class=td width=98% cellpadding=0 cellspacing=0><tr><td style=\"border-bottom: solid black 1px;\" bgcolor=eeeeee><b>$topicinfo[topic]</b> by $topicinfo[starter] (<a href=forums.php?view=topics>back</a>)</td></tr>";	print "<tr><td>$topicinfo[body]</td></tr></table><br>";		$rsel = mysql_query("select * from replies2 where topic_id=$topicinfo[id] order by id asc");	while ($reply = mysql_fetch_array($rsel)) {		print "<center><table class=td width=98% cellpadding=0 cellspacing=0><tr><td bgcolor=eeeeee style=\"border-bottom: solid black 1px;\"><b>$reply[starter]</b> says... (<a href=forums2.php?view=topics>back</a>)</td></tr>";		print "<tr><td>$reply[body]</td></tr></table><br>";	}	print "</center><form method=post action=forums2.php?reply=$topicinfo[id]>";	print "Add Reply:<br><textarea name=rep cols=30 rows=3>Body</textarea><br><input type=submit value=\"Add Reply\"></form>";}// Add Topicif ($action == addtopic) {	if (empty ($title) || empty ($body)) {		print "You must fill all fields.";		include("footer2.php");		exit;	}	mysql_query("insert into topics2 (topic, body, starter) values('$title2', '$body', '$stat[user]')") or die("Could not add topic.");	print "Added topic. Click <a href=forums2.php?view=topics>here</a> to go back to the topic list.";}// Add Replyif ($reply) {$exists = mysql_num_rows(mysql_query("select * from topics2 where id=$reply"));	if ($exists <= 0) {		print "No such topic.";		include("footer2.php");		exit;	}	if (empty ($rep)) {		print "You must fill out all fields.";		include("footer2.php");		exit;	}mysql_query("insert into replies2 (starter, topic_id, body) values('$stat[user]', $reply, '$rep')") or die("Could not add reply.");print "Reply added. Click <a href=forums2.php?topic=$reply>here</a>.";}?><?phpinclude("footer.php");?>

i still got the parse error tho

i took this exact code from a copy page with a few small changes like topics to topics2 and replies to replies2 and forums.php to forums2.php

so i dont no why one has a parse error and another one doesnt
Edited by shadowdemon (see edit history)

Share this post


Link to post
Share on other sites

Is this $stat[rank] getting set to a value someplace we can't see, like maybe in the first include file??

Replacing this stray end angle bracket with a semi-colon might help.

if ($action == sticky){mysql_query("Update topics2 set sticky=yes where topic_id=$topic[id]");		echo "<a href="forums2.php?view=topics">back</a>">}

Share this post


Link to post
Share on other sites

Is this $stat[rank] getting set to a value someplace we can't see, like maybe in the first include file??
Replacing this stray end angle bracket with a semi-colon might help.

if ($action == sticky){mysql_query("Update topics2 set sticky=yes where topic_id=$topic[id]");		echo "<a href="forums2.php?view=topics">back</a>">}

the
$stat[rank] is included in the header.php

im about to try the code out

still got a parse error its something to do with
`','' or `';''

oh and please use the second code i posterd
Edited by shadowdemon (see edit history)

Share this post


Link to post
Share on other sites

Original:

if ($action == sticky){mysql_query("Update topics2 set sticky=yes where topic_id=$topic[id]");		echo "<a href="forums2.php?view=topics">back</a>">}
Try:
if ($action == sticky){mysql_query("Update topics2 set sticky=yes where topic_id=$topic[id]");		echo '<a href="forums2.php?view=topics">back</a>';}
Notice the single quotes on the outer parts of the echo and the semi-colon at the end.

Share this post


Link to post
Share on other sites

Original:

if ($action == sticky){mysql_query("Update topics2 set sticky=yes where topic_id=$topic[id]");		echo "<a href="forums2.php?view=topics">back</a>">}
Try:
if ($action == sticky){mysql_query("Update topics2 set sticky=yes where topic_id=$topic[id]");		echo '<a href="forums2.php?view=topics">back</a>';}
Notice the single quotes on the outer parts of the echo and the semi-colon at the end.


still have the problem. I am gonna ask my friend when he logs on if he can figure it out but if you guys cant i dont think he will be able to.

Share this post


Link to post
Share on other sites

echo "<a href="forums2.php?action=sticky">sticky the topic</a>";...echo "<a href="forums2.php?view=topics">back</a>";

Those "s need to be escaped, so that you have:

echo "<a href=\"forums2.php?action=sticky\">sticky the topic</a>";...echo "<a href=\"forums2.php?view=topics\">back</a>";
jlhaslip noticed the second one but missed the first. What happens is the computer sees echo "<a href="forums2.php?action=sticky" (this is a full command) >sticky the topic</a>"; (this is a second command, but there doesn't seem to be a ';' seperating them). I hope that helps. Also, with syntax errors like this, the computer will usually give you a line number that the error occured on. If you have this kind of problem again, it's really helpful to specify what the few lines around that line number are.

Share this post


Link to post
Share on other sites

echo "<a href="forums2.php?action=sticky">sticky the topic</a>";...echo "<a href="forums2.php?view=topics">back</a>";

Those "s need to be escaped, so that you have:

echo "<a href=\"forums2.php?action=sticky\">sticky the topic</a>";...echo "<a href=\"forums2.php?view=topics\">back</a>";
jlhaslip noticed the second one but missed the first. What happens is the computer sees echo "<a href="forums2.php?action=sticky" (this is a full command) >sticky the topic</a>"; (this is a second command, but there doesn't seem to be a ';' seperating them). I hope that helps. Also, with syntax errors like this, the computer will usually give you a line number that the error occured on. If you have this kind of problem again, it's really helpful to specify what the few lines around that line number are.

 

ty for the help

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.