Need help fixing my PHP

welp I just need 1 quick help, I have this on my website as

<? $checkplayersonlinequery = mssql_query("SELECT CurrPlayer FROM ServerStatus WHERE ServerID=1");
$checkplayergetrow = mssql_fetch_row($checkplayersonlinequery);
echo "<span name='player'>" . $checkplayergetrow[0] . "</span>"; ?> 

that is meant to grab a column called “CurrPlayer” but it only outputs " . $checkplayergetrow[0] . “”; ?> on my website

To explain: I need it to echo the playercount as being the total value 1-100 depending on how many players are online according to the database.

Well, If you need a count of results, just use COUNT()…
Something like SELECT COUNT(
) FROM ServerStatus WHERE ServerID=1;
OR better, after you run the query and get results, use mssql_num_rows($checkplayersonlinequery) to find the count of the rows. Then, to display all of them, you would need to parse thru the rows of data and display each. the $checkplayergetrow is an array of data for the fields in the database. Index zero may not be what you think it is. To debug it, use something like this just before displaying the data in your echo:
$temp=print_r($checkplayergetrow, 1);
echo “< pre>”.$temp."< /pre>";
This creates a dump of the array of info in the row and allows you to view it to see what you really are getting out of the row.

Hope this helps…

Sponsor our Newsletter | Privacy Policy | Terms of Service