do you see any syntax error in this piece of code?
<?php
include("../includes/connection.php");
include("../includes/set_time_zone.php");
$log_username=$_SESSION['username']; //correctly pirints the username currently loged in when echo
$log_dt=date("Y/m/d h:i:s A"); //correctly prints the time and date when echo
function reglog($event){
$query = "INSERT into logs VALUES ('','$event','$log_username','$log_dt')";
if ($result=mysql_query($query) or die (mysql_error()));
}
?>
Your error is in the function. $log_username and $log_dt are NOT part of the function scope. You passed in $event but you forgot to pass in $log_username and $log_dt.
function reglog($event){
$log_username=$_SESSION['username'];
$log_dt=date("Y/m/d h:i:s A");
$query = "INSERT into logs VALUES ('','$event','$log_username','$log_dt')";
if ($result=mysql_query($query) or die (mysql_error()));
}
You need to include session_start() and if $_SESSION[‘username’] is not set you have to set it.
Example:
<?php
session_start();
include("../includes/connection.php");
include("../includes/set_time_zone.php");
if (!isset($_SESSION['username']))
{
$_SESSION['username'] = "log_username";
}
$log_username=$_SESSION['username']; //correctly pirints the username currently loged in when echo
$log_dt=date("Y/m/d h:i:s A"); //correctly prints the time and date when echo
function reglog($event){
$query = "INSERT into logs VALUES ('','$event','$log_username','$log_dt')";
if ($result=mysql_query($query) or die (mysql_error()));
}
?>
I’m not sure why you getting error for $log_dt.
EDIT: If reglog() was called it would generate those errors as logic_earth stated.