-3

Hi whay i have this errors:

Notice: Undefined index: reporter in /home/test.php on line 17

Line 17 is :
if ($row_logs['reporter'] == sanitize($member['members_seo_name']))

Notice: Undefined index: reports in /home/test.php on line 25

Line 25 is : if ($row_max['reports'] == 4 && $row_max['rep_expire'] >= time() )

<?php
require_once("init.php");
global $db, $core;

$member['members_seo_name'] = "maximum";


      $username = "plusmaster";
      $rep_logs = $db->query("SELECT reporter FROM rep_logs WHERE reported = '" . $username . "'");
      $row_logs = $db->fetchrow($rep_logs);

    if ($row_logs['reporter'] == sanitize($member['members_seo_name']))
          echo 'Before that you are reported this user.';


      $seoname = sanitize($member['members_seo_name']);   
      $rep_max = $db->query("SELECT * FROM rep_max WHERE reporter = '" . $seoname . "'");
      $row_max = $db->fetchrow($rep_max);

    if ($row_max['reports'] == 4 && $row_max['rep_expire'] >= time() )
         echo 'Max report time reached.';

?>
canfos
  • 3
  • 1
  • possible duplicate of [PHP: "Notice: Undefined variable" and "Notice: Undefined index"](http://stackoverflow.com/questions/4261133/php-notice-undefined-variable-and-notice-undefined-index) – ʰᵈˑ Feb 09 '15 at 13:17
  • 2
    Check your return values. A large percentage of questions on StackOverflow would be solved simply by checking that return values actually are what they are assumed to be. – Sverri M. Olsen Feb 09 '15 at 13:18
  • 1
    See [this](http://stackoverflow.com/questions/28410685/undefined-index-reporter-and-reports#comment45154859_28410685) – ʰᵈˑ Feb 09 '15 at 13:19

1 Answers1

1

Means your query doesn't return any result use a check for count return rows

if(count($row_max) > 0) {
  // your code
}

also you can check with more ways with

is_array($row_max) or isset($row_max['reports'])

and according to array result you need to use array index like

if ($row_max[2] == 4 && $row_max[3] >= time() )
Rakesh Sharma
  • 13,680
  • 5
  • 37
  • 44