raa Posted November 8, 2006 Share Posted November 8, 2006 Hi, first off I have no experience with php. I have a Counterstrike HL/1 gameserver that I which to query with a php script, determine if its on or off, then display the appropriate message(ON/OFF), or image. Like so;http://www.game-monitor.com/server-stat.php?ip=63.211.221.143:27015&style=0&text=000000&link=0000FF&back=F2F6FC&border=8F9DB4&body=I'm pretty sure the server cannot be queried using TCP, it has to be UDP.This is what I've got so far and am receiving this error. Please help if you can. Parse error: syntax error, unexpected ',', expecting ')' in /dir/dir/dir/status3.php on line 6[code]<?php$host = "63.211.221.143";$PORT = "27015";$connect = fsockopen ("UDP: //$host", $port, $errno, $errstr, 2);socket_set_timeout ($connect, 2);fwrite (, "\ xFF \ xFF \ xFF \ xFFping \ x00" $connect);fread ($connect, 4);$ping = fread (, 1 $connect);fclose ($connect);if ($ping == "j") {print ("HLDS IS ON<br>");} ELSE {print ("HLDS IS OFF<br>");}?>[/code] Link to comment https://forums.phpfreaks.com/topic/26629-parse-error-syntax-error-unexpected-expecting/ Share on other sites More sharing options...
Caesar Posted November 8, 2006 Share Posted November 8, 2006 [code]<?phpfwrite (, "\ xFF \ xFF \ xFF \ xFFping \ x00" $connect);?>[/code]There lies your error. Link to comment https://forums.phpfreaks.com/topic/26629-parse-error-syntax-error-unexpected-expecting/#findComment-121787 Share on other sites More sharing options...
raa Posted November 8, 2006 Author Share Posted November 8, 2006 well yeah, that's line 6. but what is wrong with it? Link to comment https://forums.phpfreaks.com/topic/26629-parse-error-syntax-error-unexpected-expecting/#findComment-121796 Share on other sites More sharing options...
Caesar Posted November 8, 2006 Share Posted November 8, 2006 [quote author=raa link=topic=114326.msg465120#msg465120 date=1163021993]well yeah, that's line 6. but what is wrong with it?[/quote]Look at the parameters. You have a comma, but nothing before it. Then, you don't have anything seperating your string from the $connect variable.Edit...and that is just for starters. :-PCheck out.... http://us2.php.net/fwrite Link to comment https://forums.phpfreaks.com/topic/26629-parse-error-syntax-error-unexpected-expecting/#findComment-121799 Share on other sites More sharing options...
raa Posted November 8, 2006 Author Share Posted November 8, 2006 ok well like I said before I have no experience with pHp. I've looked at online manuals and other scripts related to what I'm doing and get lost real fast. That script is just something I found. Could anyone help me get a small script going that does the job? Link to comment https://forums.phpfreaks.com/topic/26629-parse-error-syntax-error-unexpected-expecting/#findComment-121814 Share on other sites More sharing options...
raa Posted November 8, 2006 Author Share Posted November 8, 2006 its seems many people have issues with trying to connect using UDP.[code]<?php$host = "udp://70.58.73.251";$port = "27019";$output = @fsockopen($host, $port, $errno, $errstr, 2); if (!$output) { echo "<img src='gfx/status2.gif' alt='Offline' />"; } else { echo"<img src='gfx/status1.gif' alt='Online' />";@fclose($output);}?>[/code]that script shoes server is online even if it offline.anyone figured out that problem yet. Link to comment https://forums.phpfreaks.com/topic/26629-parse-error-syntax-error-unexpected-expecting/#findComment-121838 Share on other sites More sharing options...
raa Posted November 8, 2006 Author Share Posted November 8, 2006 A little info on the udp issue;[quote]But UDP wont report OFFLINE. I read that Unlike TCP, UDP is a connectionless protocol.Due to the nature of UDP, if you send a packet and don't get a response it automatically assumes the port is open. That's why you always get the online status.[/quote]http://www.phpfreaks.com/forums/index.php/topic,102678.0.htmlI know its possible cuz gamemonitor queries servers. Link to comment https://forums.phpfreaks.com/topic/26629-parse-error-syntax-error-unexpected-expecting/#findComment-121842 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.