php - Call to a member function query() on null -
i have weird problem php file adding database. installed php7 on server (when php 5.6 installed works well) , getting error:
php message: php fatal error: uncaught error: call member function query() on null in /srv/patch/newdb.php:26
newdb file.
<?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 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 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); ?>
Comments
Post a Comment