Discuss Anything: Another Parse Error - Discuss Anything

Jump to content


Welcome to KnowledgeSutra - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!
Page 1 of 1

Another Parse Error lol Rate Topic: -----

#1 User is offline   shadowdemon 

  • Super Member
  • PipPipPipPipPipPipPipPipPip
  • Group: Kontributors
  • Posts: 209
  • Joined: 13-September 05
  • Current Mood: Current Mood:

Posted 07 April 2006 - 10:27 PM

<?php $title = "Forums"; include("header.php"); ?>

<?php
// the Topic List
if ($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 Topic


if ($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 Topic
if ($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 Reply
if ($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>.";
}
?>

<?php
include("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
0


Page 1 of 1

Other Replies To This Topic

#2 User is offline   Tyssen 

  • PipPipPipPipPipPipPipPipPipPipPip
  • Group: Kontributors
  • Posts: 1,161
  • Joined: 09-May 05
  • Location:Brisbane, QLD
  • Current Mood: Current Mood: None Chosen

Posted 07 April 2006 - 11:00 PM

There's no ; after this:

echo "<a href="forums2.php?view=topics">back</a>">
0

#3 User is offline   jlhaslip 

  • Insert Custom Title Here
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • Group: [MODERATOR]
  • Posts: 5,035
  • Joined: 24-July 05
  • Gender:Male
  • Location:Linux, DOS and Windows…the good, the bad and the ugly
  • Interests:http://jim.haslip.googlepages.com/home
  • myCENT:43.02
  • Spam Patrol
  • Current Mood: Current Mood: None Chosen

Posted 07 April 2006 - 11:07 PM

Try:

		if ($stat[rank] ==  admin )

0

#4 User is offline   Tyssen 

  • PipPipPipPipPipPipPipPipPipPipPip
  • Group: Kontributors
  • Posts: 1,161
  • Joined: 09-May 05
  • Location:Brisbane, QLD
  • Current Mood: Current Mood: None Chosen

Posted 07 April 2006 - 11:37 PM

That won't work Jim. It's gotta be a string, doesn't it?
0

#5 User is offline   jlhaslip 

  • Insert Custom Title Here
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • Group: [MODERATOR]
  • Posts: 5,035
  • Joined: 24-July 05
  • Gender:Male
  • Location:Linux, DOS and Windows…the good, the bad and the ugly
  • Interests:http://jim.haslip.googlepages.com/home
  • myCENT:43.02
  • Spam Patrol
  • Current Mood: Current Mood: None Chosen

Posted 07 April 2006 - 11:47 PM

Maybe you are right.

What's with this?
=view   

0

#6 User is offline   shadowdemon 

  • Super Member
  • PipPipPipPipPipPipPipPipPip
  • Group: Kontributors
  • Posts: 209
  • Joined: 13-September 05
  • Current Mood: Current Mood:

Posted 08 April 2006 - 12:07 AM

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 List
if ($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 Topic


if ($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 Topic
if ($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 Reply
if ($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>.";
}
?>

<?php
include("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

This post has been edited by shadowdemon: 08 April 2006 - 11:39 AM

0

#7 User is offline   jlhaslip 

  • Insert Custom Title Here
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • Group: [MODERATOR]
  • Posts: 5,035
  • Joined: 24-July 05
  • Gender:Male
  • Location:Linux, DOS and Windows…the good, the bad and the ugly
  • Interests:http://jim.haslip.googlepages.com/home
  • myCENT:43.02
  • Spam Patrol
  • Current Mood: Current Mood: None Chosen

Posted 08 April 2006 - 12:50 AM

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>">
}

0

#8 User is offline   shadowdemon 

  • Super Member
  • PipPipPipPipPipPipPipPipPip
  • Group: Kontributors
  • Posts: 209
  • Joined: 13-September 05
  • Current Mood: Current Mood:

Posted 08 April 2006 - 11:41 AM

View Postjlhaslip, on Apr 7 2006, 08:50 PM, said:

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

This post has been edited by shadowdemon: 08 April 2006 - 11:45 AM

0

#9 User is offline   jlhaslip 

  • Insert Custom Title Here
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • Group: [MODERATOR]
  • Posts: 5,035
  • Joined: 24-July 05
  • Gender:Male
  • Location:Linux, DOS and Windows…the good, the bad and the ugly
  • Interests:http://jim.haslip.googlepages.com/home
  • myCENT:43.02
  • Spam Patrol
  • Current Mood: Current Mood: None Chosen

Posted 08 April 2006 - 03:25 PM

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.
0

#10 User is offline   shadowdemon 

  • Super Member
  • PipPipPipPipPipPipPipPipPip
  • Group: Kontributors
  • Posts: 209
  • Joined: 13-September 05
  • Current Mood: Current Mood:

Posted 08 April 2006 - 08:16 PM

View Postjlhaslip, on Apr 8 2006, 11:25 AM, said:

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.
0

#11 User is offline   WindAndWater 

  • Advanced Member
  • PipPipPipPipPipPipPip
  • Group: Kontributors
  • Posts: 106
  • Joined: 01-April 06
  • myCENT:ZERO
  • Current Mood: Current Mood:

Posted 09 April 2006 - 06:20 AM

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.
0

#12 User is offline   shadowdemon 

  • Super Member
  • PipPipPipPipPipPipPipPipPip
  • Group: Kontributors
  • Posts: 209
  • Joined: 13-September 05
  • Current Mood: Current Mood:

Posted 13 April 2006 - 08:13 PM

View PostWindAndWater, on Apr 9 2006, 02:20 AM, said:

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
0

Share this topic:


Page 1 of 1


Similar Topics Collapse

  Topic Forum Started By Stats Last Post Info
New Replies Icon Help Needed With Silly Error PHP Programming wappy 
  • 8 Replies
  • 815 Views
Hot Topic (New) Icon What Website Do You Find Your Always Goin Back To?
and not trap17 lol
Website Discussion lil_chris 
  • 77 Replies
  • 6,698 Views
New Replies Icon Site Error Message
temporarily unavailable
your Secret HideOut E-Sector 
  • 1 Reply
  • 841 Views
New Replies Icon Newest Sig...
I have sorta improved....lol
Showoff MaineFishing45 
  • 2 Replies
  • 566 Views
Hot Topic (New) Icon You Guys Must Help Me.. I Beg Of You..
This is hard lol. Such a rare story!
Dating Advice Swordnyx 
  • 18 Replies
  • 1,376 Views
New Replies Icon Site Error your Secret HideOut demongaara 
  • 2 Replies
  • 893 Views
New Replies Icon '24' The Movie
24-hours long? :P LOLZ!!!
General Talk serverph 
  • 10 Replies
  • 1,680 Views
New Replies Icon Lol I Tought Someone Hacked My Site General Talk Roly 
  • 9 Replies
  • 1,505 Views
New Replies Icon Wordpress Error Help Urgent Website Discussion gisellebebegirl 
  • 7 Replies
  • 579 Views
Locked Topic Icon Omg I Got Banned! Lol General Talk Danny 
  • 3 Replies
  • 546 Views
New Replies Icon Attachments Gallery Help Needed
errors help help
PHP Programming onemillion 
  • 10 Replies
  • 1,071 Views
New Replies Icon Attachments Need Help With 'drive Not Ready' Error
Operating System : Windows XP Pro x64
Operating Systems bluedragon 
  • 7 Replies
  • 730 Views
New Replies Icon Ftp Error
help :(
Questions & Queries Laos 
  • 2 Replies
  • 804 Views
New Replies Icon License Validation Failed
I get this error when i try to log in on Xisto.
Technical Support Strikee 
  • 10 Replies
  • 612 Views
Hot Topic (New) Icon Another Wassie's Love
lol
Dating Advice wassie 
  • 16 Replies
  • 2,087 Views
New Replies Icon Help - Bad_pool_header Error And Max Payne Games jarro2002 
  • 1 Reply
  • 1,063 Views
New Replies Icon Posting Count Error? Questions & Queries desimela 
  • 4 Replies
  • 3,158 Views
New Replies Icon Hello
Finally introducing myself lol
Introductions ashton 
  • 7 Replies
  • 1,976 Views
Locked Topic Icon Error In Processing The Sign Up Free Web Hosting: Misc. Requests jayron 
  • 1 Reply
  • 691 Views
New Replies Icon Script Not Working :s
mysql errors
PHP Programming AlternativeNick 
  • 5 Replies
  • 1,260 Views

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Google Fan :-) We Recommend Firefox.     Customize / Settings Connect Us on facebook