Beispiel #1
0
include "whoisonline_config.php";
include "dbclass.php";
$count = 0;
if ($_SESSION['entrytime'] == "") {
    $_SESSION['entrytime'] = time();
}
if (file_exists("install.php")) {
    echo "Who Is Online Security:<br>Please Remve <b>install.php</b>.";
    exit;
}
$db1 = new dbClass();
$db1->setDBVars($dbhost, $dbname, $dbuser, $dbpass);
$db1->openConnection();
$ip = $_SERVER['REMOTE_ADDR'];
$sql = "SELECT COUNT(*) FROM `{$dbname}`.`{$dbtable}` WHERE `ip`='{$ip}';";
$rowOut = $db1->queryRowArray($sql);
$ip_exists = $rowOut[0];
if ($ip_exists > 0) {
    $sql = "SELECT COUNT(*) FROM `{$dbname}`.`{$dbtable}`";
    $rowOut = $db1->queryRowArray($sql);
    $count = $rowOut[0];
} else {
    $db1->execCommand("INSERT INTO `{$dbname}`.`{$dbtable}` (`ip`) VALUES ('{$ip}');");
    $sql = "SELECT COUNT(*) FROM `{$dbname}`.`{$dbtable}`;";
    $rowOut = $db1->queryRowArray($sql);
    $count = $rowOut[0];
}
echo "<table>";
echo "<tr><td>" . $txtVisitors . "</td><td>" . $count . "</td></tr>";
echo "<tr><td>" . $txtYourIP . "</td><td>" . $ip . "</td></tr>";
echo "</table>";
Beispiel #2
0
// table, how to get the number
// of rows returned for a query
// and how to Insert a new record
// into an existing database table
/////////////////////////////////////
include "dbclass.php";
$a = new dbClass('localhost', 'test', 'root', 'password');
$rowOut = array();
$tblList = array();
$dbList = array();
$numRows = 0;
// Set connection variables and open database connection ------------------------------------
$a->openConnection();
// Execute Single Row Query and display results ---------------------------------------------
$sql = "SELECT * FROM `test1`;";
$rowOut = $a->queryRowArray($sql);
// Count the number of rows returned in a query ----------------------------------------------
$numRows = $a->queryNumRows();
$numCols = $a->queryNumCols();
echo "<table border=1 bordercolor=black>";
for ($i = 0; $i < $numCols; $i++) {
    echo "<tr><td><b>Column {$i}:</b></td><td>" . $rowOut[$i] . "</td></tr>";
}
echo "</table><br><br>";
echo "<b>Number of Columns in Query is:</b> " . $numCols . "<br>";
echo "<b>Number of Rows in Query is:</b> " . $numRows . "<br>";
// Execute an SQL command like INSERT or UPDATE ----------------------------------------------
$a->execCommand("INSERT INTO `test1` (column1,column2,column3,column4) VALUES ('1','2','3','4');");
$a->closeConnection();
?>