V
V
vkup2018-03-17 13:37:36
PHP
vkup, 2018-03-17 13:37:36

What is the problem Notice: Undefined index?

How to solve the problem? The site displays:

Notice: Undefined index: user_id in /home/admin/web/defaultdomain/public_html/inc/variables.php on line 8
Notice: Undefined index: user_hash in /home/admin/web/defaultdomain/public_html/inc/variables.php on line 9
Notice: Undefined index: section in /home/admin/web/defaultdomain/public_html/inc/variables.php on line 11

variables.php
$user_id = (int) $_COOKIE['user_id'];
$user_hash = $_COOKIE['user_hash'] ? $db->escape($_COOKIE['user_hash']) : 2;

$cat_name = $_GET['section'] ? $_GET['section'] : 'likes';

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis, 2018-03-17
@vkup

$user_id = isset($_COOKIE['user_id'])?(int) $_COOKIE['user_id']:0;
$user_hash = (isset($_COOKIE['user_hash']) && ($_COOKIE['user_hash'])) ? $db->escape($_COOKIE['user_hash']) : 2;
$cat_name = (isset($_GET['section']) && $_GET['section']) ? $_GET['section'] : 'likes';

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question