Jump to content

Parse error: syntax error, unexpected ',', expecting ')'


raa

Recommended Posts

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]

[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. :-P

Check out.... http://us2.php.net/fwrite
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?
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.
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.html


I know its possible cuz gamemonitor queries servers.

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.