Parse error: syntax error, unexpected T_VARIABLE

asammustafa143

New Member
Messages
20
Reaction score
0
Points
0
Help Please

on line 70

70:mysql_query("UPDATE users SET kills = kills + 1 WHERE username = '$gangsterusername')");
71:mysql_query("UPDATE users SET deathmessage = '$dmsg' WHERE username = '$ban'");
72:mysql_query("INSERT INTO modkill(victim,reason,killer,killerip,rankid)
73:VALUES ('$ban','$reason','$gangsterusername','$userip','$banrank')");
74:mysql_query("INSERT INTO attempts(username,victim,ip,type)
75:VALUES ('$gangsterusername','$ban','$userip','1')");
76:echo"<font color=white face=verdana size=1>You shot at </font><a href=viewprofile.php?username=$ban><font color=white face=verdana size=1>$ban</a>, he died!</font>";
 

cybrax

Community Advocate
Community Support
Messages
764
Reaction score
27
Points
0
Give this a try and where ever else you have put a $php variable into an mySQL query

Not sure kills+1 is going to work either, work it out before then assign to a variable

HTML:
"UPDATE users SET kills = kills + 1 WHERE username = ' " . $gangsterusername . " ')"
 
Last edited:

asammustafa143

New Member
Messages
20
Reaction score
0
Points
0
Parse error: syntax error, unexpected '"' in /home/am1996/public_html/dupebgkill.php on line 70

:/
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Please post the lines before #70. That is usually where the real problem is located.

And you do have a problem with line #70, but that should show up when the query is run. Remove the ')' that is inside the double quotes.
 

asammustafa143

New Member
Messages
20
Reaction score
0
Points
0
if(isset($_POST['do'])){
if(!$name){}
elseif($banrows < '1'){echo'<font color=white face=verdana size=1>No such user!</font>';}
elseif($status == 'Dead'){echo'<font color=white face=verdana size=1>User is already dead!</font>';}
elseif(($banrank >= '50')&&($playerrank < 100)){echo'<font color=white face=verdana size=1>Want to be demoted?</font>';}
elseif($ban == 'RaeqwoN
else{
mysql_query("UPDATE users SET kills = kills + 1 WHERE username = '$gangsterusername')");
mysql_query("UPDATE users SET deathmessage = '$dmsg' WHERE username = '$ban'");
mysql_query("INSERT INTO modkill(victim,reason,killer,killerip,rankid)
VALUES ('$ban','$reason','$gangsterusername','$userip','$banrank')");
mysql_query("INSERT INTO attempts(username,victim,ip,type)
VALUES ('$gangsterusername','$ban','$userip','1')");
echo"<font color=white face=verdana size=1>You shot at </font><a href=viewprofile.php?username=$ban><font color=white face=verdana size=1>$ban</a>, he died!</font>";
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
elseif($ban == 'RaeqwoN <=======================
 

asammustafa143

New Member
Messages
20
Reaction score
0
Points
0
"And you do have a problem with line #70, but that should show up when the query is run. Remove the ')' that is inside the double quotes."

What do you mean by that? im slightly confused
 

asammustafa143

New Member
Messages
20
Reaction score
0
Points
0
They're 3 on line 70

---------- Post added at 08:49 PM ---------- Previous post was at 08:43 PM ----------

Would someone be able to correct this please

if(isset($_POST['do'])){
if(!$name){}
elseif($banrows < '1'){echo'<font color=white face=verdana size=1>No such user!</font>';}
elseif($status == 'Dead'){echo'<font color=white face=verdana size=1>User is already dead!</font>';}
elseif(($banrank >= '50')&&($playerrank < 100)){echo'<font color=white face=verdana size=1>Want to be demoted?</font>';}
elseif($ban == 'RaeqwoN
else{
mysql_query("UPDATE users SET kills = kills + 1 WHERE username = '$gangsterusername')");
mysql_query("UPDATE users SET deathmessage = '$dmsg' WHERE username = '$ban'");
mysql_query("INSERT INTO modkill(victim,reason,killer,killerip,rankid)
VALUES ('$ban','$reason','$gangsterusername','$userip','$ banrank')");
mysql_query("INSERT INTO attempts(username,victim,ip,type)
VALUES ('$gangsterusername','$ban','$userip','1')");
echo"<font color=white face=verdana size=1>You shot at </font><a href=viewprofile.php?username=$ban><font color=white face=verdana size=1>$ban</a>, he died!</font>";

70:mysql_query("UPDATE users SET kills = kills + 1 WHERE username = '$gangsterusername')");
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Please use
PHP:
, [html] or [code] tags (as appropriate) to separate and format code. It will be a particular help here, as the code colorizing will highlight the error.

The [URL="http://x10hosting.com/forums/programming-help/162529-php-begin-deprecation-ext-mysql-start-moving-your-development-pdo-now.html"]mysql extension[/URL] is outdated and being deprecated. Switch to mysqli or PDO. Both support prepared statements, which let you keep values separate from statements. Interpolating values directly into statements is dangerous, as it can introduce [url=http://unixwiz.net/techtips/sql-injection.html]SQL injection vulnerabilities[/url].

[quote="cybrax, post: 867451"]Give this a try and where ever else you have put a $php variable into an mySQL query 
...
[PHP]"UPDATE users SET kills = kills + 1 WHERE username = ' " . $gangsterusername . " ')"
[/QUOTE]
Theres no need to use the concatenation operator with double quotes. It just adds unnecessary characters and reduces readability.

Not sure kills+1 is going to work either, work it out before then assign to a variable
It works just fine. Performing the addition in PHP adds needless complexity and SQL queries.
 
Last edited:

cybrax

Community Advocate
Community Support
Messages
764
Reaction score
27
Points
0
Thanks for that mission, it all helps.
 
Top