Jump to content
MakeWebGames

I need help with PHP


CHAMAVELI

Recommended Posts

Hey guys I receive this error when i open this PHP page:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/gangland/public_html/upgrade.php on line 15

The PHP code is:

<?php

include "globals.php";


if($ir['exp']==$ir['level']*975)
{
$ir['level']+=1;
$ir['exp']=$expu;
$ir['brave']+=2;
$ir['maxbrave']+=2;
$ir['hp']=(975*$ir['level']);
$ir['maxhp']=(975*$ir['level']);
mysql_query("UPDATE users SET level=level+1,brave=brave+2,maxbrave=maxbrave+2,
hp='{975*$ir['level']}',maxhp='{975*$ir['level']}' WHERE userid=$userid") or die(mysql_error());
mysql_query("UPDATE users SET upgrade=upgrade-1 WHERE userid=$userid") or die(mysql_error());

print"Congratulations! You upgraded to level [b]{$ir['level']}[/b]!";

}
else
{
die("You do not have enough XP to upgrade your level at this time.");

}

$h->endpage;
?>

The error code line is (line 14-16):

mysql_query("UPDATE users SET level=level+1,brave=brave+2,maxbrave=maxbrave+2,
hp='{975*$ir['level']}',maxhp='{975*$ir['level']}' WHERE userid=$userid") or die(mysql_error());
mysql_query("UPDATE users SET upgrade=upgrade-1 WHERE userid=$userid") or die(mysql_error());
Link to comment
Share on other sites

Re: I need help with PHP

Take the

'

out of the querys......

 

mysql_query("UPDATE users SET level=level+1,brave=brave+2,maxbrave=maxbrave+2, hp={975*$ir['level']} ,maxhp={975*$ir['level']} WHERE userid=$userid") or die(mysql_error());
mysql_query("UPDATE users SET upgrade=upgrade-1 WHERE userid=$userid") or die(mysql_error());

 

Personallly I would change it to something like...

 

$hp = 975 * $ir['level'];
$maxhp = 975 * $ir['level'];

mysql_query("UPDATE users SET level=level+1, brave=brave+2, maxbrave=maxbrave+2, hp=$hp, maxhp=$maxhp WHERE userid=$userid") or die(mysql_error());

The other query is fine.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...