Hello all,
I recently upgraded my MySQL on my dedicated server box for compatibility issues with a script and now my other script just wont work.
<?
define('CFG_FILE', 'C:/InetPub/wwwroot/status/GameQ/class.gameq.cfg.php');
define('INC_PATH', 'C:/InetPub/wwwroot/status/GameQ/inc/');
require_once('c:/inetpub/wwwroot/status/GameQ/class.gameq.php');
require_once('C:/InetPub/wwwroot/status/functions.php');
/* You can put this in other file and just include it */
function OpenDb($hostname,$uid,$pwd,$dbname){
$link = @mysql_pconnect($hostname,$uid,$pwd);
if($link && mysql_select_db($dbname)){
return($link);
}
else{
return(FALSE);
}
}
function QueryIntoArray($query){
settype($retval,"array");
$result= mysql_query($query);
if(!$result){
print "Query Failed";
}
for($i=0;$i<mysql_num_rows($result);$i++){
for($j=0;$j<mysql_num_fields($result);$j++){
$retval[$i][mysql_field_name($result,$j)] = mysql_result
($result,$i,mysql_field_name($result,$j));
}//end inner loop
}//end outer loop
return $retval;
}//end function
OpenDb("localhost","root","**","**");
settype($servid,"array");
$query = "select * from tc_services ORDER BY SERVER_IP";
$servid = QueryIntoArray($query);
for($i=0;$i<count($servid);$i++){
$ip=$servid[$i]["SERVER_IP"];
$gameid=$servid[$i]["GAME_ID"];
$server=$servid[$i]["SERVER_PORT"];
$slot=$servid[$i]["SLOTS"];
$user=$servid[$i]["DISPLAY_NAME"];
$id=$servid[$i]["SERVICE_ID"];
$game = $servid[$i]["GAME_ID"];
$port = $servid[$i]["SERVER_PORT"];
$players = $current;
$overall = $servid[$i]["SLOTS"];
include('C:/InetPub/wwwroot/status/gameq.php');
mysql_error();
print $ip;
echo ':';
print $server;
echo ' - ';
print $user;
echo ' - ';
print $hostname;
echo ' /n ';
sqlcheck($id, $game, $ip, $port, $hostname, $current, $overall, $map);
}
?>
Its a server scanning script i made to scan my companies gaming server and then insert the results into the database. Code is dirty but hey!
Error is:
Query Failed<br />
<b>Warning</b>: mysql_num_rows(): supplied argument is not a valid MySQL result
resource in <b>C:\InetPub\wwwroot\status\cron.php</b> on line <b>25</b><br />
I run this PHP script in a DOS box/Batch script as its running on a windows. It worked fine for months when scanning a different database for the results until I changed the Database. Tried doing the mysql error to find if its a SQL error but it just still showed the same error as above 🙁
Any ideas?