I'm making a VERY basic ticket system. Where basically if an SQL query or something doesn't run properly. It will insert a few bits of data into a MySQL table so the admin can run through and see what has happened and try to fix it.
<?php
$stamp = gettimestamp();
$error = $db->error;
$page = basename($_SERVER['PHP_SELF']);
echo "Error Updating! Please contact your IT Admin Team!";
echo "Stamp: ".$stamp;
echo "Error: ".$error;
echo "Page: ".$page;
echo "Email: ".$email;
$ticketSQL="INSERT INTO `db744544270`.`supportTickets` (`timestamp`, `problem`, `page`, `user`) VALUES ('$stamp', '$error', '$page', '$email')";
if ($db->query($ticketSQL) === TRUE) {
echo '<script>alert("Record Upated!");</script>';
header( "refresh:5;url=index.php" );
//var_dump($sql);
//echo "<script>location.href = 'index.php';</script>";
} else {
echo "Error AGAIN!";
}
?>
Above is the code I am running and basically I have put this into a file and just include that file on every page where I need it. For example inside the error handling of an if statement. If query TRUE-> YAY, else query FALSE->include ticket page.
Like I said...very basic.. Whenever I run the page and at the moment I am getting an error from another query but that's a question for a different time :) this is the current error i get...
Error updating record: Unknown column '1' in 'where clause'
Fatal error: Call to undefined function gettimestamp() in /homepages/38/d735513801/htdocs/includes/supportTicket.php on line 2
I have no idea why it is saying it's undefined. I have tried changing the type and everything. It just will not insert into the table, I feel like I'm being stupid but I can't see why it's not working...