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!
- - - - -

A Parse Error Problem


20 replies to this topic

#1 shadowdemon

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 209 posts

Posted 01 April 2006 - 01:22 AM

<?php include ("header.php"); 
echo "<br>Welcome to the construction site. Randomly we will update this place with stuff you can do. Currently we are offering you to make a building where you can make trade gold for ap or platinum for ap. The cost of this project is all 10k silver wood.</br>"; 

if ($stat[construction] <= 1) 
{ 
print 'Would you like to start the building';
echo "<a href="construction.php?action=construct">construct</a> ";
)
if ($action == construct) 
{ 
print "you have started construction $stat[user]...<br><br>"; 
mysql_query("Update players Set construction=yes where id=stat[id] "); 
//a verification should be made if the player has the right amount of silver wood before making that query 
//else you'll end up with - numbers.. 
mysql_query("Update players Set silver wood = $stat[silverwood]-10000 where stat[id] "); 
mysql_query("Update players Set construction = stat[construction]+1 where stat[id] "); 
print "</table><br>"; 
print "Or you can always... <a href=city.php>go back</a>."; 
} 
} 
if ($stat[constructed] => 2) 
{ 
$prices = mysql_query("select * from market"); 
$pa = mysql_fetch_array($prices); 
$plat_price = $pa[ap]; 
if ($action != buy) { 
print "Ap isn't always a stable-priced commodity... right now its $plat_price credits an ap. How much you want?"; 
print "<form method=post action=construction.php?action=buy>"; 
print "I want <input type=text name=plat> ap. <input type=submit value=Buy>"; 
print "</form>"; 
} else { 
$plat = str_replace("--","", $plat); 
$cost = ($plat * $plat_price); 
if ($cost > $stat[credits] || $plat <= 0) { 
print "You cant afford that! (<a href=pshop.php>back</a>)"; 
} else { 
mysql_query("update players set credits=credits-$cost where id=$stat[id]"); 
mysql_query("update players set ap=ap+$plat where id=$stat[id]"); 
print "You got <b>$plat</b> ap for <b>$cost</b> credits."; 
} 
} 

?> 

<? include ("footer.php"); ?> 

and the error is

Quote

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

if thes dont show up as quotes could a mod fix it please.



this is for a text based game so it may seem different. But it shouldnt matter since the parse error shouldnt interfer with it.

Edited by jlhaslip, 01 April 2006 - 06:28 PM.


#2 jlhaslip

    Insert Custom Title Here

  • [MODERATOR]
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,040 posts
  • Gender:Not Telling
  • Location:Linux, DOS and Windows…the good, the bad and the ugly
  • myCENT:81.07
  • Spam Patrol

Posted 01 April 2006 - 01:26 AM

What you have currently:
if ($stat[construction] <= 1)
{
print 'Would you like to start the building';
echo "<a href="construction.php?action=construct">construct</a> ";
)
And what you might need to change is the last end parenthesis to a right-curly brace. Like this:
if ($stat[construction] <= 1)
{
print 'Would you like to start the building';
echo "<a href="construction.php?action=construct">construct</a> ";
}


#3 Tyssen

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPip
  • 1,161 posts
  • Location:Brisbane, QLD

Posted 01 April 2006 - 01:27 AM

This line:

echo "<a href="construction.php?action=construct">construct</a>";
should be:
echo '<a href="construction.php?action=construct">construct</a>';
or:
echo "<a href=\"construction.php?action=construct\">construct</a>";
PHP is going to execute anything within the " " or ' ' so in your case, it gets to the " after the href and then stops.

#4 shadowdemon

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 209 posts

Posted 01 April 2006 - 02:31 PM

now i get this
Parse error: parse error in /home/www/dancha42.madpage.com/construction.php on line 20

i hate parse errors. im gonna try and figure it out myself but if you what to fix your suggestions are welcomed

#5 jlhaslip

    Insert Custom Title Here

  • [MODERATOR]
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,040 posts
  • Gender:Not Telling
  • Location:Linux, DOS and Windows…the good, the bad and the ugly
  • myCENT:81.07
  • Spam Patrol

Posted 01 April 2006 - 03:43 PM

you have :

if ($stat[constructed] => 2) 

try:

if ($stat[constructed] >= 2) 


#6 shadowdemon

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 209 posts

Posted 01 April 2006 - 04:19 PM

View Postjlhaslip, on Apr 1 2006, 10:43 AM, said:

you have :

if ($stat[constructed] => 2) 

try:

if ($stat[constructed] >= 2) 

doesnt fix the parse error but that is becuase it isnt on line 20 so you might have fixed a later parse error but i still need some help with the line 20 one

#7 jlhaslip

    Insert Custom Title Here

  • [MODERATOR]
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,040 posts
  • Gender:Not Telling
  • Location:Linux, DOS and Windows…the good, the bad and the ugly
  • myCENT:81.07
  • Spam Patrol

Posted 01 April 2006 - 05:17 PM

It might not like the whitespace and carriage return here:
if ($action == construct)
{
print "you have 
Try this for the If statements:
if ($action == construct) {
print "you have 


#8 truefusion

    Coincidence is non-sequitur, therefore everything has a reason for its existence (except if they are eternal).

  • [MODERATOR]
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 3,216 posts
  • Gender:Male
  • Location:No, not there. Not there either. Yes, you'll never figure it out.
  • Interests:God, Christianity.
  • myCENT:86.16

Posted 01 April 2006 - 05:28 PM

On line 2, the <br> tag doesnt work like that.

And for this:

Quote

if ($stat[construction] <= 1)
{
print 'Would you like to start the building';
echo "<a href=\"construction.php?action=construct\">construct</a> ";
)
I think the thing in bold is the problem. May want to change it to: }

Edited by truefusion, 01 April 2006 - 05:29 PM.


#9 shadowdemon

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 209 posts

Posted 01 April 2006 - 06:16 PM

View Posttruefusion, on Apr 1 2006, 12:28 PM, said:

On line 2, the <br> tag doesnt work like that.

And for this:

I think the thing in bold is the problem. May want to change it to: }
fixed that earlier


View Postjlhaslip, on Apr 1 2006, 12:17 PM, said:

It might not like the whitespace and carriage return here:
if ($action == construct)
{
print "you have 
Try this for the If statements:
if ($action == construct) {
print "you have 


ill try this out ty

i thought spaces dont matter in php
yeah i was right spaces dont matter cause i still get

Parse error: parse error in /home/www/dancha42.madpage.com/construction.php on line 19 (was 20 but then the space made it drop down one)


the error is around here

mysql_query("Update players Set silver wood = $stat[silverwood]-10000 where stat[id] ");
mysql_query("Update players Set construction = stat[construction]+1 where stat[id] ");
print "</table><br>";
print "Or you can always... <a href=city.php>go back</a>.";
}
}
if ($stat[constructed] >= 2)

but i dont see what is wrong (match this up with the code but it is around this area more specifically print "</table<br>":angry:

Edited by shadowdemon, 01 April 2006 - 06:22 PM.


#10 jlhaslip

    Insert Custom Title Here

  • [MODERATOR]
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,040 posts
  • Gender:Not Telling
  • Location:Linux, DOS and Windows…the good, the bad and the ugly
  • myCENT:81.07
  • Spam Patrol

Posted 01 April 2006 - 06:25 PM

View Postshadowdemon, on Apr 1 2006, 11:16 AM, said:

fixed that earlier
ill try this out ty

i thought spaces dont matter in php
yeah i was right spaces dont matter cause i still get

Parse error: parse error in /home/www/dancha42.madpage.com/construction.php on line 19 (was 20 but then the space made it drop down one)
Sometimes an editor will plant invisible things in there. I happen to have an Editor which shows the carriage returns and tabs, etc so I thought maybe there was something out of place perhaps.

You have changed the code a little bit to fix some previous errors. Would you mind re-posting the code and please identify the error line for us. PHP is funny about parse errors. It identifies a line by number where it senses the error, but it might be several lines back that the actual cause exists.




Reply to this topic


This post will need approval from a moderator before this post is shown.

  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users