Why doesn't the function call?

There are two pages: index.php and actions.php.

In the file actions.php is the following code:
<? session_start(); date_default_timezone_set('Europe/Moscow'); $getMicro = microtime(true); # a timestamp with microseconds

class actions {

 public function logoutFromSite() {

 if (($_GET['act'] == 'logout' and $_GET['reason'] == 'ds' and $_GET['next'] == '/index.php')) {
 unset($_SESSION); # Here it is clear

 include_once($_SERVER['DOCUMENT_ROOT'].'/modules/security/cookie.php'); # Work with Cookie 
 $cookie--->delete('s_uid'); # In fact, these lines are optional for the problems, maybe 
 $cookie->delete('a_statusHash'); #they are not needed, this is cookie

 header('Location:' . $_GET['next'] . "); # Throw on /index.php
}
 return true;
}
}


In the file index.php is the following code:
include_once($_SERVER['DOCUMENT_ROOT'].'/modules/security/actions.php'); # the Plug-in class actions

 $actions = new actions; # all good Here, problems yet
 $actions->logoutFromSite(); # Calling a single function, which is in the class actions, and we have a 500 error either immediately or when you have specified a GET-request.


I can not understand what I'm doing wrong. 500 Error, though, and make everything so..

But this code works fine:
class actions {
 public function online(){

 if(isset($_SESSION['uid'])) { echo 'ALL GOOD'; }

 return true;
}
}


Point the finger at my mistake, and better to rewrite my code to get it working.
June 14th 19 at 20:40
1 answer
June 14th 19 at 20:42
Solution
I would have to start advised to enable error reporting.
But in General I don't like the line:
include_once($_SERVER['DOCUMENT_ROOT'].'/modules/security/cookie.php')

Most likely a critical error it generates. Check the file that way.
Tell me this: I'm fine, no errors niiiiiiice, all the same class and so on, but var_export($SelectUserInfo); returns this:
mysqli_result::__set_state(array(
'current_field' => NULL,
'field_count' => NULL,
'lengths' => NULL,
'num_rows' => NULL,
'type' => NULL,
))


The fool is clear that there is no connected database, or call need something different, help

public function getUser() {

 if(isset($_SESSION['uid'])) {

 include($_SERVER['DOCUMENT_ROOT'].'/modules/bd/connect.php'); # Pluggable database

 $SelectUserInfo = $mysqli->query('SELECT * FROM `users` WHERE `profile`="'.$_SESSION['uid'].'"');
var_export($SelectUserInfo);
 if($SelectUserInfo->num_rows !== 0){
 while($infoUser = $SelectUserInfo->fetch_array()) {
 $first_name = $infoUser['first_name'];
 $last_name = $infoUser['last_name'];
 $iswho = $infoUser['who'];
 $regid = $infoUser['id'];
 $avatar = $infoUser['photo_min'];
 $online = $infoUser['lastjoin'];
 $onlineunixtime = $infoUser['lastjoin_unixtime'];
 #$profile_id = $infoUser['profile'];
}

 $uid = $_SESSION['uid']; # Profile VK ['uid'] in the global array $_SESSION

 $getID = $mysqli->query('SELECT `id` FROM `users` WHERE `profile` = "'.$uid.'"')->fetch_array(); # retrieve from database user ID in the system

 $id = $getID['id']; # user ID in the system

 include($_SERVER['DOCUMENT_ROOT'].'/modules/security/permissions.php'); # Definition privileges

 include($_SERVER['DOCUMENT_ROOT'].'/modules/security/server.php'); # Log info and load

 $mysqli->query('UPDATE `users` SET `lastjoin`="'.date('Y. m.d H:i:s').'",
`lastjoin_unixtime`="'.time().'",
`ip_user`="'.$userIP.'",
`hostname`="'.gethostbyaddr($userIP).'",
`browser`="'.$userBrowser.'",
`platform`="'.$userPlatform.'",
`refer`="'.$userReferalPage.'",
`useragent`="'.$userAgent.'",
`method`="'.$_SERVER['REQUEST_METHOD'].'",
 `page`="'.$home.'" WHERE `profile`="'.$uid.'"'); # Put online coming user on the site

 } else { header('Location: /try'); }
 } else { header('Location: /actions/login'); }
 return true;
 }
- Zachariah_Weima commented on June 14th 19 at 20:45
Yes no. With the base all right. She'll even answer it gives is correct. What makes you think something's wrong? Do
var_export($SelectUserInfo->fetch_assoc());
Or in the query where the error. You can see what query is generated
echo 'SELECT * FROM `users` WHERE `profile`="'.$_SESSION['uid'].'"';

And to try his hands in the DB insert. Or is it still $mysqli->error look. - Giles_Luettgen18 commented on June 14th 19 at 20:48

Find more questions by tags PHP