PsyScript: getting experiments done
|
/*
function safe_db_query ($database = "", $query = "", $connection = "") {
global $query_debug;
if (empty($query)) { return FALSE; }
if (!empty($query_debug)) { print " $query \n"; }
$result = mysql_query($database, $query, $connection)
or die("ack! query failed: "
." errorno=".mysql_errno()
."error=".mysql_error()
."query=".$query
);
return $result;
}
$Base = "http://www.maccs.mq.edu.au";
$URL= $PHP_SELF;
$connection = mysql_connect('localhost', 'tim', 'connect2');
if (!$connection) {
print("Cannot connect to database. Call Tim. ");
exit();
}
$result=safe_db_query("Counters","SELECT * FROM Count WHERE Base='$Base' AND URL='$URL'", $connection);
while ($row = mysql_fetch_row($result)) {
$ChkBase=$row[0];
$ChkURL=$row[1];
$ChkCount=$row[2];
$Count=$ChkCount;
}
if ($ChkURL == ""){
safe_db_query("Counters","INSERT INTO Count VALUES ('$Base','$URL','0')", $connection);
$Count=0;
}
$Count++;
safe_db_query("Counters","UPDATE Count SET Number='$Count' WHERE Base='$Base' AND URL='$URL'");
$result=safe_db_query("Counters","SELECT * FROM Count WHERE Base='$Base' AND URL='$URL'", $connection);
while ($row = mysql_fetch_row($result)) {
$Base=$row[0];
$URL=$row[1];
$Count=$row[2];
}
echo $Count;
*/
?>hits
|