Jump to content

Annoying unexpected }


Twist3d

Recommended Posts

Again, I'm probably making a rookie mistake here, but this is really annoying me and I see no way to fix it.

 

Parse error: syntax error, unexpected '}' in ****/index.php on line 350

Here is my line 350

 

if (!isset($_SESSION['endOfTimer'])){
    $endOfTimer = time() + 20;
    $_SESSION['endOfTimer'] = $endOfTimer;
} else {
    $timeTilEnd = $_SESSION['endOfTimer'] - time();
    echo 'You have '.$timeTilEnd.' seconds left.';
}

if($timeTilEnd < 0) { 
if ($status == "Online"){
mysql_query("UPDATE data SET uptime=uptime+1 WHERE id='$id'")
} elseif($status == "Offline"){
mysql_query("UPDATE data SET downtime=downtime+1 WHERE id='$id'")
}

session_destroy();
?>
<META HTTP-EQUIV=Refresh CONTENT="1">
<?php
}
?>

 

What i'm simply trying to do, is to get the string data, check if it is offline or online, and sort them according to that string in the SQL database.

It keeps giving me that annoying error, and it is just an If statement..

Again, I do have a habit for missing simple things, sorry if this is the case.

Link to comment
https://forums.phpfreaks.com/topic/208402-annoying-unexpected/
Share on other sites

if (!isset($_SESSION['endOfTimer'])){
    $endOfTimer = time() + 20;
    $_SESSION['endOfTimer'] = $endOfTimer;
} else {
    $timeTilEnd = $_SESSION['endOfTimer'] - time();
    echo 'You have '.$timeTilEnd.' seconds left.';
}

if($timeTilEnd < 0) { 
if ($status == "Online"){
mysql_query("UPDATE data SET uptime=uptime+1 WHERE id='$id'");
} elseif($status == "Offline"){
mysql_query("UPDATE data SET downtime=downtime+1 WHERE id='$id'");
}

session_destroy();
?>
<META HTTP-EQUIV=Refresh CONTENT="1">
<?php
}
?>

 

If you notice, the two MySQL queries do not end with a semi-colon.

 

if ($status == "Online"){
mysql_query("UPDATE data SET uptime=uptime+1 WHERE id='$id'")
} elseif($status == "Offline"){
mysql_query("UPDATE data SET downtime=downtime+1 WHERE id='$id'")
}

Link to comment
https://forums.phpfreaks.com/topic/208402-annoying-unexpected/#findComment-1089036
Share on other sites

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.