DragonPrime - LoGD Resource Community

Coding Support => v0.9.7 Technical Help => Topic started by: Ironman on August 08, 2004, 04:51:24 PM



Title: Frustrating Parse Error!
Post by: Ironman on August 08, 2004, 04:51:24 PM
I'm trying to write what I thought was a simple forest event, but I keep running into a parse error which I don't understand.  It is driving me up a wall, and it must be something terrible small that I just keep looking past.

Here's the code:

<?
if (!isset($session)) exit();

/*
Old Hag Special Forest Event
for Legend of the Green Dragon v0.9.7 +JT
Version 1.0 (08/08/04)
By Gary M. Hartzell

This is my remake of the Old Hag Forest Event from LORD.
Just upload it into your "special" directory.
*/

$hp = $session[user][hitpoints];
$maxhp = $session[user][maxhitpoints];
$halfhp = $hp /2;

if ($HTTP_GET_VARS[op]=="")
{
output("As you are wandering through the forest, an ugly old hag appears before you.`n`n");
output("\"Give me a gem, and I'll make ye feel better,\" she screeches.`n`nDo you give her the gem?");
addnav("Give her a gem","forest.php?op=yes");
addnav("Don't do it","forest.php?op=no");
   $session[user][specialinc]="oldhag.php";
}
else if ($HTTP_GET_VARS[op]=="no")
{
output("\"Humph,\" replies the hag.  She waves her cane before her and vanishes.");
}
else if ($HTTP_GET_VARS[op]=="yes")
{
if ($session[user][gems] < 1)
{
output("\"Ye have no gems, ye lyin' fool!\" the hag screams.  She strikes you between the eyes with her cane and vanishes.");
$session[user][hitpoints -= $halfhp;
}
else
{
$session[user][gems] --;
output("She waves her cane in front of your face, and you feel a surge of energy go through your body`n`nYOU ARE COMPLETELY HEALDED, AND GAIN 1 MAX HIT POINT!");
$session[user][maxhitpoints]++;
$session[user][hitpoints = $session[user][maxhitpoints];
}
}

?>

And the error:

Parse error: parse error, expecting `']'' in /usr/www/users/imgary/logd/special/oldhag.php on line 35


I actually wanted to make it so that, if the user's hitpoints were not equal their max hit points, that they would only get healed and only get the extra max hp if they were 100% health going into the event.  However, I thought the problem was that I was screwing up my braces somewhere in the nested if/else statements.  Simplifying the script didn't help, however.

I guess this is more an php problem than an actual LOGD coding issue, but I'm pulling out my hair here!

Thanks!
 


Title: Re:Frustrating Parse Error!
Post by: Peanut_Butter_Wolf on August 08, 2004, 05:19:30 PM
you're missing a right bracket on  line 35

$session[user][hitpoints -= $halfhp;

$session[user][hitpoints] <--



Title: Re:Frustrating Parse Error!
Post by: Ironman on August 08, 2004, 05:35:53 PM
I have a closing brace on the next line.  I put in another closing brace, but get the same error.  Putting a closing brace before this line wouldn't make any sense.


Title: Re:Frustrating Parse Error!
Post by: Chojin on August 08, 2004, 08:20:45 PM
Ironman, reread Peanut_Butter_Wolf's post.

You are missing array-brackets. At the very end there is another one missing:

$session[user][hitpoints = $session[user][maxhitpoints];

should be

$session[user][hitpoints] = $session[user][maxhitpoints];


Title: Re:Frustrating Parse Error!
Post by: Ironman on August 08, 2004, 08:32:55 PM
DOH!  Okay, thank you -- both of you.

© 2019 DragonPrime - LoGD Resource Community
Email Talisman: talisman -at- gmail.com
&oeXs)2U7=V BmܲV.U e=;p\}eG )Jj} C5EH7ˤH=j } mo|*Ŋw{drV_@IV>/- TFQJ׀̀Ve}l1,V O iNYx͘$e$;
Forums: Powered by SMF 1.1.21 | SMF © 2006-2007, Simple Machines