Parse error: syntax error, unexpected T_STRING in /home/***/public_html/playground/maps.php on line 341
Line 341:
PHP Code:
$getopp="SELECT * from a_pokemon where Pokemon='$getuser3[Opponent]'";
$getopp2=mysql_query($getopp) or die("Could not get Pokemon from database.");
$getopp3=mysql_fetch_array($getopp2);
Thanks,
Danyal.
Last edited by Christian; 10-08-06 at 02:21 PM.
Reason: Please use [PHP] wrapper when posting PHP code.
Errors like this are usually caused by something missing prior to the line where the error was discovered. Post 10 or so lines before the error too.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
The script it self did not even run, it found an error with syntax, it's probably caused by not closing a tag or argument like, like...
PHP Code:
if(isset($var){$string}
PHP was expecting a ")" so it keept searching for a ")" untill it came apon one later in the script. thus everything between the if(... and the random ")" does not make sense.
$get1pokemon="SELECT * from t_pokemon where ID='$getuser3[Starter]'";
$get1pokemon2=mysql_query($get1pokemon) or die("Could not get Pokemon from database.");
$get1pokemon3=mysql_fetch_array($get1pokemon2);
$getusingp="SELECT * from t_pokemon where ID='$getuser3[$Using]'";
$getusingp2=mysql_query($getusingp) or die("Could not get Pokemon from database.");
$getusingp3=mysql_fetch_array($getusingp2);
$getp="SELECT * from a_pokemon where Pokemon='$getusingp3[Pokemon]'";
$getp2=mysql_query($getp) or die("Could not get Pokemon from database.");
$getp3=mysql_fetch_array($getp2);
$getevolve="SELECT * from a_pokemon where Number='$getusingp3[Number]+1'";
$getevolve2=mysql_query($getevolve) or die("Could not get Pokemon from database.");
$getevolve3=mysql_fetch_array($getevolve2);
$getattack4="SELECT * from attacks where Attack='$getusingp3[Attack1]'";
$getattack5=mysql_query($getattack4) or die("Could not get Pokemon from database.");
$getattack6=mysql_fetch_array($getattack5);
$getattack7="SELECT * from attacks where Attack='$getusingp3[Attack2]'";
$getattack8=mysql_query($getattack7) or die("Could not get Pokemon from database.");
$getattack9=mysql_fetch_array($getattack8);
$getattack10="SELECT * from attacks where Attack='$getusingp3[Attack3]'";
$getattack11=mysql_query($getattack10) or die("Could not get Pokemon from database.");
$getattack12=mysql_fetch_array($getattack11);
$getattack13="SELECT * from attacks where Attack='$getusingp3[Attack4]'";
$getattack14=mysql_query($getattack13) or die("Could not get Pokemon from database.");
$getattack15=mysql_fetch_array($getattack14);
$UpdateMap="Update trainers set Map='$map', X='$x', Y='$y' where Username='$user'";
mysql_query($UpdateMap) or die("Could not set Map.");
function submitonce(theform){
//if IE 4+ or NS 6+
if (document.all||document.getElementById){
//screen thru every element in the form, and hunt down "submit" and "reset"
for (i=0;i<theform.length;i++){
var tempobj=theform.elements[i]
if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
//disable em
tempobj.disabled=true
}
}
}
</script>
linktext[2]="Use An Item<br><br><b>Coming Soon!</b>"
linktext[3]="Run From Battle<br><br><br><br><form method=\"POST\" onSubmit=\"submitonce(this)\"><button type=\"submit\" name=\"run\" value=\"run\" class='button2'>Escape!</button></form>"
var ns6=document.getElementById&&!document.all
var ie=document.all
function show_text(thetext, whichdiv){
if (ie) eval("document.all."+whichdiv).innerHTML=linktext[thetext]
else if (ns6) document.getElementById(whichdiv).innerHTML=linktext[thetext]
}
function resetit(whichdiv){
if (ie) eval("document.all."+whichdiv).innerHTML=''
else if (ns6) document.getElementById(whichdiv).innerHTML=''
}
</script>
$geto="SELECT * from m_pokemon where ID='$wildpoke'";
$geto2=mysql_query($geto) or die("Could not get Pokemon from database.");
$geto3=mysql_fetch_array($geto2);
$geto4="SELECT * from a_pokemon where Pokemon='$geto3[Pokemon]'";
$geto5=mysql_query($geto4) or die("Could not get Pokemon from database.");
$geto6=mysql_fetch_array($geto5);
if (isset($_POST['Attack']) && $getuser3[Refresh] == 'Yes')
{
print "<center><font face='verdana' size='2'><b>Oops! For Security Reasons Refreshing Has Been Disabled!";
}
if (isset($_POST['evolve']) && $getuser3[Refresh] == 'Evolve')
{
print "<center><font face='verdana' size='2'><b>Oops! For Security Reasons Refreshing Has Been Disabled!";
}
if (isset($_POST['evolve']) && $getusingp3[EvolveLVL] == '0')
{
print "<center><font face='verdana' size='2'><b>There Has Been An Error $getusingp3[Pokemon] Does Not Evolve!";
}
if (isset($_POST['catch']) && $getuser3[Refresh] == 'Yes')
{
print "<center><font face='verdana' size='2'><b>Oops! For Security Reasons Refreshing Has Been Disabled!";
}
if (isset($_POST['evolve']) && $getp3[EvolveLVL] != '0' && $getusingp3[Level] >= $getp3[EvolveLVL] && $getuser3[Refresh] != 'Evolve')
{
$evolution = $getp3[Evolution];
$getevo="SELECT * from a_pokemon where Pokemon='$evolution'";
$getevo2=mysql_query($getevo) or die("Could not get Pokemon from database.");
$getevo3=mysql_fetch_array($getevo2);
print "<font face='verdana' size='2'><b><center>Evolving $getusingp3[Pokemon]!</font><font face='verdana' size='1'><br><br><img src='images/Pokemon/$getusingp3[Pokemon].gif'> <img src='images/Pokemon/$getevo3[Pokemon].gif'><br><b>Congratulations!</b><br>Your $getusingp3[Pokemon] Has Evolved Into $getevo3[Pokemon]!";
$FixHP="Update t_pokemon set Pokemon='$getevo3[Pokemon]', HP='$NewHP', MHP='$NewHP' where Trainer='$user' and ID='$getusingp3[ID]'";
mysql_query($FixHP) or die("Could not fix HP.");
$SetRefresh="Update trainers set Refresh='Evolve' where Username='$user'";
mysql_query($SetRefresh) or die("Could not stop refresh.");
}
if (isset($_POST['catch']) && $getuser3[Refresh] == 'No')
{
[b]$getopp="SELECT * from a_pokemon where Pokemon='$getuser3[Opponent]'";
$getopp2=mysql_query($getopp) or die("Could not get Pokemon from database.");
$getopp3=mysql_fetch_array($getopp2);[/b]
$getopp4="SELECT * from m_pokemon where Pokemon='$getuser3[Opponent]'";
$getopp5=mysql_query($getopp4) or die("Could not get Pokemon from database.");
$getopp6=mysql_fetch_array($getopp5);
$next = $getuser3[OLevel]+1;
$next2 = $next*$next*$next;
$OHP = ($getopp3[BaseHP]/10)*$getuser3[OLevel];
if($getopp6 && $getuser3[OLevel] <= 17)
{
print "<center><font face='verdana' size='2'><b>Catch $getuser3[Opponent]!<br><br><br></b><font face='verdana' size='1'><img src='images/Pokemon/$getuser3[Opponent].gif'><br><b>$getuser3[Opponent]!</b><br><b>Level: </b>$getuser3[OLevel]<br><b>EXP: </b>$getuser3[OEXP]<br><b>Gender: </b>$getuser3[OGender]<br><br>$getuser3[Opponent]<img src='images/$getuser3[OGender].gif'> Has Been Added To Your Box!";
$SQL ="INSERT into t_pokemon (Pokemon,Trainer,Level,NLevel,EXP,EXPN,HP,MHP,Gender,Item, Attack1, Attack2, Attack3, Attack4) values('$getuser3[Opponent]','$getuser3[Username]','$getuser3[OLevel]','$next','$getuser3[OEXP]','$next2','$OHP','$OHP','$getuser3[OGender]','None','$getopp3[Attack1]','$getopp3[Attack2]','$getopp3[Attack3]','$getopp3[Attack4]')";
mysql_query($SQL) or die(mysql_error());
$SetRefresh="Update trainers set Refresh='Yes' where Username='$user'";
mysql_query($SetRefresh) or die("Could not stop refresh.");
}
if(!$getopp6 || $getuser3[OLevel] > 17)
{print "<font face='verdana' size='2'><b><center>Oops! There Was An Error Catching Pokemon!";}
}
if ((!isset($_POST['catch'])) && isset($_POST['Attack']) && $getuser3[Refresh] == 'No' && (!isset($_POST['evolve'])))
{
if($Attack == $getusingp3[Attack1])
{$ActualAttack = $getusingp3[Attack1];}
if($Attack == $getusingp3[Attack2])
{$ActualAttack = $getusingp3[Attack2];}
if($Attack == $getusingp3[Attack3])
{$ActualAttack = $getusingp3[Attack3];}
if($Attack == $getusingp3[Attack4])
{$ActualAttack = $getusingp3[Attack4];}
if($ActualAttack == '---')
{$ActualAttack = $getusingp3[Attack1];}
$getattack="SELECT * from attacks where Attack='$ActualAttack'";
$getattack2=mysql_query($getattack) or die("Could not get Pokemon from database.");
$getattack3=mysql_fetch_array($getattack2);
$getopp="SELECT * from a_pokemon where Pokemon='$getuser3[Opponent]'";
$getopp2=mysql_query($getopp) or die("Could not get Pokemon from database.");
$getopp3=mysql_fetch_array($getopp2);
$getattack4="SELECT * from attacks where Attack='$wildattack'";
$getattack5=mysql_query($getattack4) or die("Could not get Pokemon from database.");
$getattack6=mysql_fetch_array($getattack5);
if((!isset($_POST['catch'])) && $getusingp3[HP]-$damage2 <= '0' && $getuser3[OHP]-$damage <= '0')
{
print "<center><font face='verdana' size='2'><b>The Battle Is A Draw!</b></font><br><br><img src='images/Trainers/$getuser3[Team].png'><img src='images/Pokemon/$getusingp3[Pokemon].gif'><br><font face='verdana' size='1'><b>$getuser3[Username] And $getusingp3[Pokemon] Have Tied The Battle!<br></b>No Money Or EXP Points Have Been Awarded!<br><br>";
$NewHP = $getusingp3[Level]*($getp3[BaseHP]/10);
$FixHP="Update t_pokemon set HP='$NewHP', MHP='$NewHP' where Trainer='$user' and Pokemon='$getusingp3[Pokemon]'";
mysql_query($FixHP) or die("Could not fix HP.");
$SetRefresh="Update trainers set Refresh='Yes' where Username='$user'";
mysql_query($SetRefresh) or die("Could not stop refresh.");
}
if((!isset($_POST['catch'])) && $getusingp3[HP]-$damage2 <= '0' && $getuser3[OHP]-$damage > '0')
{
print "<center><font face='verdana' size='2'><b>You Have Lost!</b></font><br><br><img src='images/Trainers/$getuser3[Team].png'><img src='images/Pokemon/$getusingp3[Pokemon].gif'><br><font face='verdana' size='1'><b>$getuser3[Username] And $getusingp3[Pokemon] Have Lost The Battle!<br></b>No Money Or EXP Points Have Been Awarded!<br><br>";
$NewHP = $getusingp3[Level]*($getp3[BaseHP]/10);
$FixHP="Update t_pokemon set HP='$NewHP', MHP='$NewHP' where Trainer='$user' and Pokemon='$getusingp3[Pokemon]'";
mysql_query($FixHP) or die("Could not fix HP.");
$SetRefresh="Update trainers set Refresh='Yes' where Username='$user'";
mysql_query($SetRefresh) or die("Could not stop refresh.");
print "<center><font face='verdana' size='2'><b>Congratulations!</b></font><br><br><img src='images/Trainers/$getuser3[Team].png'><img src='images/Pokemon/$getusingp3[Pokemon].gif'><br><font face='verdana' size='1'><b>$getuser3[Username] And $getusingp3[Pokemon] Have Won The Battle!<br></b>You Have Won $";
echo round($money);
print "!<br>And $getusingp3[Pokemon] Gained ";
echo round($expgained);
print " EXP Points!<br><br>";
$LevelUP="Update t_pokemon set Level='$nextlevel1', NLevel='$nextlevel2', EXPN='$nextlevel', HP='$NewHP', MHP='$NewHP' where Trainer='$user' and ID='$getusingp3[ID]'";
mysql_query($LevelUP) or die("Could not Level UP.");
$SetEXP="Update t_pokemon set EXP='$expgained2' where Trainer='$user' and ID='$getusingp3[ID]'";
mysql_query($SetEXP) or die("Could not award EXP.");
$SetMoney="Update trainers set Money='$money2' where Username='$user'";
mysql_query($SetMoney) or die("Could not award Money.");
$NewHP = $getusingp3[Level]*($getp3[BaseHP]/10);
$FixHP="Update t_pokemon set HP='$NewHP', MHP='$NewHP' where Trainer='$user' and Pokemon='$getusingp3[Pokemon]'";
mysql_query($FixHP) or die("Could not fix HP.");
$SetRefresh="Update trainers set Refresh='Yes' where Username='$user'";
mysql_query($SetRefresh) or die("Could not stop refresh.");
}
if((!isset($_POST['catch'])) && $getusingp3[HP]-$damage2 > '0' && $getuser3[OHP]-$damage > '0')
{
$getname="SELECT * from t_pokemon where Trainer='$getuser3[Username]' and Pokemon='$getuser3[Opponent]'";
$getname2=mysql_query($getname) or die("Could not select new pokemon.");
$getname3=mysql_fetch_array($getname2);
$SetUHP="Update t_pokemon set HP='$dmg' where Trainer='$user' and Pokemon='$getusingp3[Pokemon]'";
mysql_query($SetUHP) or die("Could not deal damage2.");
$getopp="SELECT * from a_pokemon where Pokemon='$getuser3[Opponent]'";
$getopp2=mysql_query($getopp) or die("Could not get Pokemon from database.");
$getopp3=mysql_fetch_array($getopp2);
$SetRefresh="Update trainers set Refresh='No' where Username='$user'";
mysql_query($SetRefresh) or die("Could not stop refresh.");
$getattack="SELECT * from attacks where Attack='$getp3[Attack1]'";
$getattack2=mysql_query($getattack) or die("Could not get Pokemon from database.");
$getattack3=mysql_fetch_array($getattack2);
$getattack="SELECT * from attacks where Attack='$getp3[Attack1]'";
$getattack2=mysql_query($getattack) or die("Could not get Pokemon from database.");
$getattack3=mysql_fetch_array($getattack2);
$FixHP="Update t_pokemon set HP='$NewHP', MHP='$NewHP' where Trainer='$user' and Pokemon='$getpokemon3[Pokemon]'";
mysql_query($FixHP) or die("Could not fix HP.");
$SetOpponent="Update trainers set OLevel='$wildlevel', OEXP='$OEXP', OGender='$gender', Opponent='$geto3[Pokemon]', OHP='$OHP', OMHP='$OHP' where Username='$user'";
mysql_query($SetOpponent) or die("Could not set up opponent.");
$getwildopp="SELECT * from t_pokemon where Trainer='$getuser3[Username]' and Pokemon='$geto3[Pokemon]'";
$getwildopp2=mysql_query($getwildopp) or die("Could not select new pokemon.");
$getwildopp3=mysql_fetch_array($getwildopp2);
$FixHP="Update t_pokemon set HP='$NewHP', MHP='$NewHP' where Trainer='$user' and Pokemon='$getpokemon3[Pokemon]'";
mysql_query($FixHP) or die("Could not fix HP.");
$recent=date("U")-300;
$getonmap="SELECT COUNT(*) from trainers where Map='$map' AND lasttime>'$recent'";
$getonmap2=mysql_query($getonmap) or die("Could not get trainers on map,");
$getonmap3=mysql_result($getonmap2,0);
$getranks="SELECT * from trainers where Map='$map' AND Username!='$getuser3[Username]' AND lasttime>'$recent' order by userID ASC";
$getranks2=mysql_query($getranks) or die("Could not get box Pokemon.");
while($getranks3=mysql_fetch_array($getranks2))
{
Firstly, I wish you would edit this post and use the PHP code wrappers.
Secondly, I don't see any include/require files, so I am assuming that you are not using any constants. Therefore, there are a lot of other errors, some of which might be causing the error in question.
I recommend putting the following line in after your opening <?php tag -
PHP Code:
error_reporting(E_ALL);
For the constant values which should probably be quoted strings, I see a lot of code like the following -
I don't see anything specific elsewhere in the file that would cause the error listed, but start by checking and correcting any errors reported with the above... Even if just a notice error is issued, this is logged and causes a small speed penalty when your code is executed.
Edit: I executed your code and I don't get a parse error. Hmm...
I notice a couple of other things that you need to address -
You are referencing a $_SESSION variable but are not starting a session. While it is possible that your PHP installation is setup to automatically start a session, this is unlikely.
There is no code to connect to a mysql server and select a database. While it is possible you have opened a persistent connection to the mysql server elsewhere, you still need to select a database prior to executing a query.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
I did fix it, thanks. But now I got another error(In another file):
Parse error: syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' in /home/***/public_html/playground/BattleTower.php on line 421
PHP Code:
if($getuser3[Opponent] == 'Nosepass' && $getuser3[BattleTowers] == '0');
{
print "Good Job! You won the battle!";
if($getuser3[BattleTowers] == '0');
{
$0D="Update trainers set BattleTowers='1' where Username='$user'";
mysql_query($0D) or die("Contact Nackel OR Danyal");
}
$NewHP = $getusingp3[Level]*($getp3[BaseHP]/10);
$FixHP="Update t_pokemon set HP='$NewHP' where Trainer='$user' and Pokemon='$getusingp3[Pokemon]'";
mysql_query($FixHP) or die("Could not fix HP.");
Anyway, the 0D looks like it starts with the number zero. From the PHP manual -
Quote:
Variable names follow the same rules as other labels in PHP. A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???