Hi, I am having trouble coding for mysqli update. Please, somebody
tell me the correct way. I'm trying to update the "lastused" (current date)
field in "emailtbl". Somebody please tell the best way to code this.
Below is the message and following, the current code:
tell me the correct way. I'm trying to update the "lastused" (current date)
field in "emailtbl". Somebody please tell the best way to code this.
Below is the message and following, the current code:
$Fatal error: Call to undefined function curdate() in C:\xampp\htdocs\home\lastused.php on line 14
PHP:
db = new mysqli('localhost', 'root', 'pass', 'mydb');
if($db->connect_errno > 0)
{die('Unable to connect to database [' . $db->connect_error . ']');}
$sql = <<<SQL
SELECT *
FROM `emailtbl`
WHERE `id` = '$id'
SQL;
if(!$result = $db->query($sql))
{die('There was an error running the query [' . $db->error . ']');}
$lastused = $_POST['lastused'];
$lastused = curdate();
echo "last date accessed is ".$data['lastused'];
$result->free();
$db->escape_string('This is an unescape "string"');
$db->close();
?>
$update = mysqli_query($dbconnect, "UPDATE emailtbl SET
lastused = curdate() WHERE id ='$id'");
if($update == false)
{ die("UPDATE FAILED: ".mysqli_error($dbconnect)); }
echo "$lastused is the last date this account was accessed";