i have a function like this:
function record(){
$table = new table;
$clogin = new login;
$date = date("F j, Y, g:i a");
$ip = $_SERVER['REMOTE_ADDR'];
$uri = $_SERVER['REQUEST_URI'];
mysql_query("insert into log (player, date, ip, on) values ('$clogin->username', '$date', '$ip', '$uri')");
$fopen = fopen("data/log.txt", "a+");
fwrite ($fopen, "PLAYER: $clogin->username DATE: $date IP: $ip ON: $uri\n");
fclose ($fopen); }
I also have other mysql query inside another function and it’s work. And the fopen, fwrite, and fclose also executed properly. i wonder, why in this function the query didn’t work. am i wrong wrote the query?
It’s because the two fields of the table
LOGare Reserved Word in mySQL (DATEandON). Instead use back tick (`) before and after the field.Like this one: