...

View Full Version : Syntax Error. (unexpected T_VARIABLE)



Mujib
10-22-2009, 07:34 PM
Hello,

The error i get is

Parse error: syntax error, unexpected T_VARIABLE in /home/assassin/domains/realdutchserver.nl/public_html/webformysql/pstats.php on line 7

And Line 7 is

$Query = 'SELECT Level, Money, Kills, Admin, Drugs, Number, Exp, Vip, Team FROM users WHERE name = \'' . $nick . '\''; // With this query we get the information from $nick to transform it into a picture, where Kills Deaths etc are the names of the fields

And can someone tell me what a T_VARIABLE is?

Thanks In Advance,
Greets,
Mujib

godofreality
10-22-2009, 07:40 PM
change this


$Query = 'SELECT Level, Money, Kills, Admin, Drugs, Number, Exp, Vip, Team FROM users WHERE name = \'' . $nick . '\'';

to this


$Query = mysql_query("SELECT * FROM `users` WHERE `name` = '$nick'");
$row = mysql_fetch_assoc($Query);
$row['Level']; //user's level
$row['Money']; //user's money
$row['Kills']; //user's kills etc etc etc

so the format to use this data will be $row['(the column name you wish to view)']

oracleguy
10-22-2009, 09:06 PM
change this


$Query = 'SELECT Level, Money, Kills, Admin, Drugs, Number, Exp, Vip, Team FROM users WHERE name = \'' . $nick . '\'';

to this


$Query = mysql_query("SELECT * FROM `users` WHERE `name` = '$nick'");
$row = mysql_fetch_assoc($Query);
$row['Level']; //user's level
$row['Money']; //user's money
$row['Kills']; //user's kills etc etc etc

so the format to use this data will be $row['(the column name you wish to view)']

That is bad advice period, not to mention it does nothing to address the OP's problem. It is always better to specify the columns you want in a query. That way if you add additional columns later or don't actually need all the columns, you aren't wasting resources getting data you aren't going to use.

As far as the actual problem, look on line 6, are you missing a semicolon? Or a bracket? As the error says it is a syntax error and usually it means there is a problem on the line of code before whatever line it reports.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum