Woodsyx Posted June 4, 2009 Share Posted June 4, 2009 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"; ?> Quote Link to comment Share on other sites More sharing options...
taquitosensei Posted June 4, 2009 Share Posted June 4, 2009 you're missing a semi-colon here $ptime = MYSQL_QUERY("SELECT lasttime FROM idlers WHERE name='$name'") Quote Link to comment Share on other sites More sharing options...
Woodsyx Posted June 4, 2009 Author Share Posted June 4, 2009 Well that makes me feel stupid, went through and added all the semicolons that i was missing, so it works now Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.