4 Replies - 61017 Views - Last Post: 23 October 2011 - 03:18 AM Rate Topic: -----

#1 ryomadarktezuka  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 55
  • Joined: 02-August 09

HOW TO REMOVE NOTICE "UNDEFINED INDEX" ?

Posted 21 October 2011 - 11:34 PM

This is my code there's no problem with the output but there's this notice that just keeps on coming out

Notice: Undefined index: qoption in F:\USBWebserver v8_en\root\Demi\login\admin.php on line 198

Notice: Undefined index: qoption in F:\USBWebserver v8_en\root\Demi\login\admin.php on line 201

Notice: Undefined index: qoption in F:\USBWebserver v8_en\root\Demi\login\admin.php on line 204


I tried numerous ways to remove this notice like by using "error_reporting = E_ALL & ~E_NOTICE;" that's not even working for me, and I also tried to edit the settings of php.ini but it's still the same :|

I badly want to remove that notice I hope you could help me thanks a lot! God Bless!!

 <?php
		error_reporting = E_ALL & ~E_NOTICE;
		if (isset ($get['doSearch']) &&( $get['doSearch'] == 'Search') ){
		$cond = '';
	  if($get['qoption'] == 'pending') {
	  $cond = "where `approved`='0' order by date desc";
	  }
	  if($get['qoption'] == 'recent') {
	  $cond = "order by date desc";
	  }
	  if($get['qoption'] == 'banned') {
	  $cond = "where `banned`='1' order by date desc";
	  }
	  
	  if($get['q'] == '') { 
	  $sql = "select * from usertable $cond"; 
	  } 
	  else { 
	  
	  $sql = "select * from usertable where `user_email` = '$_REQUEST[q]' or `user_name`='$_REQUEST[q]' ";
	  }

	  
	  $rs_total = mysql_query($sql) or die(mysql_error());
	  $total = mysql_num_rows($rs_total);
	  
	  if (!isset($_GET['page']) )
		{ $start=0; } else
		{ $start = ($_GET['page'] - 1) * $page_limit; }
	  
	  $rs_results = mysql_query($sql . " limit $start,$page_limit") or die(mysql_error());
	  $total_pages = ceil($total/$page_limit);
	  
	  ?>




Is This A Good Question/Topic? 0
  • +

Replies To: HOW TO REMOVE NOTICE "UNDEFINED INDEX" ?

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 4154
  • View blog
  • Posts: 13,146
  • Joined: 08-June 10

Re: HOW TO REMOVE NOTICE "UNDEFINED INDEX" ?

Posted 22 October 2011 - 12:09 AM

Quote

HOW TO REMOVE NOTICE "UNDEFINED INDEX" ?

fix the problem, not the symptom.

test with isset() before you try to read the variable (like with doSearch)
Was This Post Helpful? 2
  • +
  • -

#3 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3735
  • View blog
  • Posts: 13,582
  • Joined: 08-August 08

Re: HOW TO REMOVE NOTICE "UNDEFINED INDEX" ?

Posted 22 October 2011 - 03:25 AM

I'd do it this way:
$expected = array('pending'=>"WHERE `approved`='0' ORDER BY DATE DESC", 'recent'=>"ORDER BY DATE DESC", 'banned'=>"WHERE `banned`='1' ORDER BY DATE DESC");
if(isset($get['qoption']) && array_key_exists($get['qoption'], $expected)) {
	$cond = $expected[$get['qoption']];
}
echo $cond."<br>";


By the way, $get is not the same as $_GET.
Was This Post Helpful? 2
  • +
  • -

#4 mattosse  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 22-October 11

Re: HOW TO REMOVE NOTICE "UNDEFINED INDEX" ?

Posted 22 October 2011 - 02:00 PM

Add this at the top of your file


error_reporting(E_ERROR | E_PARSE);

Was This Post Helpful? 0
  • +
  • -

#5 ryomadarktezuka  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 55
  • Joined: 02-August 09

Re: HOW TO REMOVE NOTICE "UNDEFINED INDEX" ?

Posted 23 October 2011 - 03:18 AM

View Postmattosse, on 22 October 2011 - 02:00 PM, said:

Add this at the top of your file


error_reporting(E_ERROR | E_PARSE);


thank you so much for this one sir! :D It worked for me :]
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1