I thought that I had created a good piece of code, but it seems it won't work. It uses a mySQL DB to store information in as well. Anyway, I recieve errors in the connect sub. Someone tell me what's wrong with it plz:
<?php
// configuration
$db_server = "localhost"; // servername, basicly localhost
$db_user = "root"; // username for db connection
$db_passwd = "pass"; // password for db connection
$db_name = "fileleech"; // name of the db
$tblServers = "servers";
$db = @mysql_pconnect($db_server,$db_user,$db_passwd) or error(LINE,FILE,"Could not establish connection to db server: $db_user@$db_server");
mysql_select_db($db_name,$db) or error(LINE,FILE,"could not select the db: ".$db_name);
// Add Server to DB
if($action == "connect")
{
if($name == "")
$name="noname server";
if($description == "")
$description="no description available!";
if($host == "")
$host = $REMOTE_ADDR;
$query = mysql_query("
INSERT
INTO $tblServers
( host, name, description, dateOnline )
VALUES
( '$host', '$name', '$description', '".date("YmdHis")."' ) ") or return(FALSE);
}
// Server Disconnects
if($action == "disconnect")
{
if($name == "")
$name="noname server";
if($description == "")
$description="no description available!";
if($host == "")
$host = $REMOTE_ADDR;
$query = mysql_query("
DELETE
FROM $tblServers
WHERE
host = '$host' ") or return(FALSE);
}
// Show Servers
if($action == "showservers")
{
$query = mysql_query("
SELECT *
FROM $tblServers
ORDER BY name ASC ") or return(FALSE);
while($data = mysql_fetch_array($query))
echo $data["name"].",".$data["host"].",".$data["description"]."\n";
}
php?>