Jump to content

Parse error: Syntax error, unexpected T variable HUGE PROBLEM


TeddyKiller

Recommended Posts

I'm getting "Parse error: syntax error, unexpected T_VARIABLE in /home/katarra/public_html/inventory.php on line 32"

 

Line 32 is "$query2"

It's a mess, I'll explain why.

 

$query - Fetches attr and value from the database items. (We don't know what the attr and value is as its different for each item, so it depends on the item picked) Then turns it into $stat['attr'] and value. Works

 

$query1 - Searches users, on $stat['attr'] (as we don't know what attribute it'll be) then turns it into $userstat[' ... '] The reason being.. is that we don't know what the value of $stat['attr'] is so basically.. it'd be $userstat["$stat['attr']"] This will hold a value (A number) The query itself.. Works

 

$query2 - Updates the users table where $stat['atr'] is, and the value of that collum will be $userstat["$stat['attr']"] PLUS(+) $stat['value'] Does not work

 

I changed $stat['attr'] to $thing, so it'll be $userstat["$thing"] assuming it wouldn't cause an error. Though it does.

Can anyone correct this for me?

 

{
$query = $db->execute("select `attr`, `value` from `items` where `id`=?", array($_GET['id'])); //Select stats from database according to equipped item ID
$stat = $query->fetchrow(); //Fetches the row
$query1 = $db->execute("select `".$stat['attr']."` from `users` where `id`=?", array($player->id)); //Select user stats from database
$userstat = $query1->fetchrow(); //Fetches the row
$thing = $stat['attr']
$query2 = $db->execute("update `users` set `".$stat['attr']."`=? where `id`=?",array($userstat["$thing"] + $stat['value'],$player->id));
} 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.