我的PHP文件存在奇怪的问题,我在数据库中添加了一些东西。我刚刚在我的服务器上安装了php7(安装PHP 5.6时一切正常)我收到错误:
PHP消息:PHP致命错误:未捕获错误:呼叫成员 函数query()在/srv/patch/newDB.php:26
上的null
newDB文件。
<?php
session_start();
require_once 'connectDB.php';
$data = json_decode(file_get_contents("php://input"));
$username = mysqli_real_escape_string($connect, $data->username);
$task = mysqli_real_escape_string($connect, $data->task);
$dept = mysqli_real_escape_string($connect, $data->dept);
$state = mysqli_real_escape_string($connect, $data->state);
$task_start = mysqli_real_escape_string($connect, $data->task_start);
$task_end = mysqli_real_escape_string($connect, $data->task_end);
$login = mysqli_real_escape_string($connect, $data->login);
$deadline = mysqli_real_escape_string($connect, $data->deadline);
$priority = mysqli_real_escape_string($connect, $data->priority);
if($_SESSION['type']=='Admin') {
$query = "INSERT into tasks_main (username,task,dept,status,task_start,task_end,deadline,task_time,priority) VALUES ('$login','$task','$dept','$state','$task_start','$task_end','$deadline','$task_time','$priority')";
}else {
$query = "INSERT into tasks_main (username,task,dept,status,task_start,task_end,deadline,task_time,priority) VALUES ('$username','$task','$dept','$state','$task_start','$task_end','$deadline','$task_time','$priority')";
}
mysqli_query($connect, $query);
echo true;
mysqli_close($connect);
?>