So basically I want to redirect to some php code after I click an event, so I can use an update query. But I'm not able to get the event ID to the php page. Right now I have this.

 eventClick: function(info) { 
     location.href = "update_task.php?id="+event.id;        
    },

PHP code:

<?php
require_once 'conn.php';
if($_GET['id'] != ""){
    $id = $_GET['id'];
    $conn->query("UPDATE `task` SET `status` = 'Done' WHERE `id` = $id") or die(mysqli_errno());
    header('location: calendar.php');
}

?>

Right now it's giving this error

Warning: mysqli_errno() expects exactly 1 parameter, 0 given in /storage/ssd1/202/9375202/public_html/update_task.php on line 5

Thanks in advance

1 Answers

1
really_operator On

The mysqli_errno() requires a parameter in PHP, that's what it is telling you. According to the docs (https://www.php.net/manual/en/mysqli.errno.php), you need to pass in the mysqli connection.

$conn->query("UPDATE `task` SET `status` = 'Done' WHERE `id` = $id") or die(mysqli_errno($conn));

Since you are using a mysqli object, you should also just be able to get the errno property as well, which may be preferred.

$conn->query("UPDATE `task` SET `status` = 'Done' WHERE `id` = $id") or die($conn->errno);