懒人日志
<?php
function mysql_put_contents($table, $message, $database = NULL, $when = NULL, $host = NULL, $user = NULL, $pass = NULL) {
if($host)
mysql_connect($host, $user, $pass);
if($database)
mysql_select_db($database);
$qry = "CREATE TABLE IF NOT EXISTS `$table` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`when` TIMESTAMP DEFAULT NOW(),
`message` TEXT NOT NULL
);";
$result = mysql_query($qry);
if($result === FALSE)
return FALSE;
$qry = "INSERT INTO `$table` VALUES(NULL, ".($when ? $when : 'NULL').", '".mysql_real_escape_string($message)."');";
$result = mysql_query($qry);
if($result === FALSE)
return FALSE;
return TRUE;
}
?>