Jump to content

[SOLVED] Parse error: syntax error, unexpected T_VARIABLE


Woodsyx

Recommended Posts

So I'm trying to write a bit of php that uses a script someone else wrote to grab data from a Game Server and take that data and add it to a mysql database. I can attach the other php script if that is somehow causing the error.

 

I get this error...

Parse error: syntax error, unexpected T_VARIABLE in /f1/content/woodsyx/public/egoIDLE/lib/example2.php on line 41

 

Any help would be appreciated.

 

<?php

require_once 'sourceserver.class.php';

/*
* Checks if the Server is online
*
*/
    $server = new SourceServer( "174.36.42.204", 27015 );

    if ( !$server->isValidSourceServer() ) {
        die( $server->getError() );
    }

/*
* Declare mySQL vars
*
*/
$host = “******”; // Don’t know? Try localhost
$username = “******”; // Your MySQL username
$password = “*****”; // Your MySQL password
$db = “****”; // The database name you selected earlier


$dbh = mysql_connect($hostname, $username, $password);//Connects to DB
//or die(“Unable to connect to mysql”);
$selected = mysql_select_db($db,$dbh);
//or die(“Could not select database”);



while ( $player = $server->getNextPlayer() ){//Creates loop to cycle through players.

if( $player['points'] == 0){//Check if player has zero points thus spectating.
	$name = $player['name']; //var for the players name
	$value= MYSQL_QUERY("SELECT name FROM idlers WHERE name='$name'");
	if(  $value == $name){
	//Check if name already has entry
	$ptime = MYSQL_QUERY("SELECT lasttime FROM idlers WHERE name='$name'")
	//Retreives the last max idle time
	$connection = $player['connected'];
	$time = substr($connection, 0, 1);//Converts time in min
	$time = (int)$time * 60;
	$time2 = substr($connection, 0, 1);
	$time = $time + (int)$time2;
	//Retreives total idle time so far.
	$ttime = MYSQL_QUERY("SELECT totaltime FROM idlers WHERE name='$name'")
	if ($ptime <= $time){//Check if last idle is larger than current idle.
						//If true they are continuing their current idle

		//Add Current time - Counted time to Previous Total
		$ttime += $time - $ptime;
	}
	else{
	//Add current time to total time.
	$ttime += $time
	}
   	
//Update totaltime
MYSQL_QUERY("UPDATE idlers SET time='$ttime' WHERE name='$name'")	
//Sets new max idle time to current idle time
MYSQL_QUERY("UPDATE idlers SET lasttime='$time' WHERE name='$name'")

}
else{//Create a new table entry with the correct data.
	$time = substr($player['connected'], 0, 1) * 60;//Converts time in min
	$time += substr($player['connected'], 0, 1);
	$name = $player['name'];
	$ttime = $time;
	$ptime = $time;

  $result=MYSQL_QUERY("INSERT INTO idllers (totaltime, time, name, lasttime)".
      "VALUES ('$ttime', '$time', '$name', '$ptime')"); 
}
}
else{ 

die("Did not add or update any database entry");
   }

}

    //confirm
   echo "Query Finished"; 
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.