TeddyKiller Posted March 14, 2010 Share Posted March 14, 2010 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)); } Link to comment https://forums.phpfreaks.com/topic/195216-parse-error-syntax-error-unexpected-t-variable-huge-problem/ Share on other sites More sharing options...
slurpee Posted March 14, 2010 Share Posted March 14, 2010 You need a semicolon after: $thing = $stat['attr']; Link to comment https://forums.phpfreaks.com/topic/195216-parse-error-syntax-error-unexpected-t-variable-huge-problem/#findComment-1026006 Share on other sites More sharing options...
TeddyKiller Posted March 14, 2010 Author Share Posted March 14, 2010 Oh ****, yeah. I didn't see that. Link to comment https://forums.phpfreaks.com/topic/195216-parse-error-syntax-error-unexpected-t-variable-huge-problem/#findComment-1026009 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.