+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Parse error: syntax error, unexpected T_VARIABLE

  1. #1
    asammustafa143 is offline x10Hosting Member asammustafa143 is an unknown quantity at this point
    Join Date
    May 2011
    Posts
    20

    Unhappy Parse error: syntax error, unexpected T_VARIABLE

    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>";

  2. #2
    cybrax's Avatar
    cybrax is offline x10 Elder cybrax is on a distinguished road
    Join Date
    Aug 2009
    Location
    UK
    Posts
    699

    Re: Parse error: syntax error, unexpected T_VARIABLE

    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 Code:
    "UPDATE users SET kills = kills + 1 WHERE username = ' " . $gangsterusername . " ')"
    Last edited by cybrax; 11-04-2011 at 03:32 PM.
    The code must flow.
    Project 157: Latest UK Jobs direct to your mobile phone
    New Domain under construction: Lovelogic.net
    home for some new projects that we can't keep here ;)


  3. #3
    asammustafa143 is offline x10Hosting Member asammustafa143 is an unknown quantity at this point
    Join Date
    May 2011
    Posts
    20

    Re: Parse error: syntax error, unexpected T_VARIABLE

    Parse error: syntax error, unexpected '"' in /home/am1996/public_html/dupebgkill.php on line 70

    :/

  4. #4
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: Parse error: syntax error, unexpected T_VARIABLE

    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.
    Nothing is always absolutely so.

  5. #5
    asammustafa143 is offline x10Hosting Member asammustafa143 is an unknown quantity at this point
    Join Date
    May 2011
    Posts
    20

    Re: Parse error: syntax error, unexpected T_VARIABLE

    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>";

  6. #6
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: Parse error: syntax error, unexpected T_VARIABLE

    elseif($ban == 'RaeqwoN <=======================
    Nothing is always absolutely so.

  7. #7
    asammustafa143 is offline x10Hosting Member asammustafa143 is an unknown quantity at this point
    Join Date
    May 2011
    Posts
    20

    Re: Parse error: syntax error, unexpected T_VARIABLE

    "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

  8. #8
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: Parse error: syntax error, unexpected T_VARIABLE

    Count your parenthesis .
    Nothing is always absolutely so.

  9. #9
    asammustafa143 is offline x10Hosting Member asammustafa143 is an unknown quantity at this point
    Join Date
    May 2011
    Posts
    20

    Re: Parse error: syntax error, unexpected T_VARIABLE

    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')");

  10. #10
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Parse error: syntax error, unexpected T_VARIABLE

    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 mysql extension 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 SQL injection vulnerabilities.

    Quote Originally Posted by cybrax View Post
    Give this a try and where ever else you have put a $php variable into an mySQL query
    ...
    PHP Code:
    "UPDATE users SET kills = kills + 1 WHERE username = ' " $gangsterusername " ')" 
    Theres no need to use the concatenation operator with double quotes. It just adds unnecessary characters and reduces readability.

    Quote Originally Posted by cybrax View Post
    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 by misson; 11-04-2011 at 08:38 PM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Parse error: syntax error, unexpected T_ELSE
    By feven05 in forum Free Hosting
    Replies: 6
    Last Post: 07-14-2011, 02:07 PM
  2. Replies: 0
    Last Post: 04-18-2011, 07:15 AM
  3. Parse error: syntax error, unexpected T_ELSE
    By whathappenswhen53 in forum Programming Help
    Replies: 3
    Last Post: 08-21-2010, 08:10 AM
  4. Parse error: syntax error, unexpected '{'
    By bigbubbax in forum Programming Help
    Replies: 2
    Last Post: 03-07-2010, 08:36 PM
  5. Replies: 9
    Last Post: 10-11-2007, 11:45 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers