Solved

error_reporting(E_ALL)......

Posted on 2007-03-31
6
359 Views
Last Modified: 2013-12-12
Hello.
I v added error_reporting(E_ALL);  at the top of my page and i m geting some errors like...

Notice: Undefined variable: photo_category_list in C:\Program Files\xampp\htdocs\homebody\homebody.php on line 867

Notice: Undefined index: s_cat in C:\Program Files\xampp\htdocs\homebody\homebody.php on line 867

when..
$result = mysql_query( "SELECT category_id,category_name FROM gallery_category ORDER BY category_name" );
     while( $row = mysql_fetch_array( $result ) )
     {
                    $photo_category_list .= '<option value="'.$row[1].'" '.($row[1]== $_SESSION["s_cat"]? "selected":"").'>'.$row[1].'</option>';    <<<<<<<<<<<<<<867 line
     }

Can you PLS explain me what i m doing wrong??
0
Comment
Question by:NTGrE
  • 3
  • 2
6 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18829022
that error means that the array item "s_cat" in the session variable array does not exist.
to get rid of the warning, you could do this:

$result = mysql_query( "SELECT category_id,category_name FROM gallery_category ORDER BY category_name" );
     while( $row = mysql_fetch_array( $result ) )
     {
                    $photo_category_list .= '<option value="'.$row[1].'" '.($row[1]==@ $_SESSION["s_cat"]? "selected":"").'>'.$row[1].'</option>';    <<<<<<<<<<<<<<867 line
     }

however, that depends on the fact if you might want to react differently on the existance or non-existance of that item in the array
0
 
LVL 12

Expert Comment

by:str_kani
ID: 18829108
also you can set something like this to avoid notices...

error_reporting(E_ALL ^ E_NOTICE);

http://au3.php.net/error_reporting
0
 

Author Comment

by:NTGrE
ID: 18829455
angelIII
As far as understand the @ hide the error..Right??
I just wonder if these errors(notices) indicates that something is wrong for security.
example...
Notice: Undefined variable: photo_category_list in ..........etc......
What means UNDEFINED ??? There is a way to define it ???
iv try
$photo_category_list="";
and the error is gone.

str_kani
thnx ...but i dont want to hide the error msg...i want to understand why this error displayed
and if means something for my security..
0
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 18829491
>As far as understand the @ hide the error..Right??
yes

>Notice: Undefined variable: photo_category_list in ..........etc......
>What means UNDEFINED ??? There is a way to define it ???
>iv try
>$photo_category_list="";
>and the error is gone.
exactly. that error will appear when you try to use a variable (ie it's value) before you have declared it like you have found out.

>but i dont want to hide the error msg...i want to understand why this error displayed
good!

actually, your initial code should be written more like this, in regards to the warning:
$s_cat = "";
if (is_set($_SESSION["s_cat"])) { $s_cat = $_SESSION["s_cat"]; }

$result = mysql_query( "SELECT category_id,category_name FROM gallery_category ORDER BY category_name" );
     while( $row = mysql_fetch_array( $result ) )
     {
                    $photo_category_list .= '<option value="'.$row[1].'" '.($row[1]== $s_cat ? "selected":"").'>'.$row[1].'</option>';    <<<<<<<<<<<<<<867 line
     }

0
 

Author Comment

by:NTGrE
ID: 18831467
Thnx angelIII.....
One last Question..
Leaving an UNDEFINED variable can cause me security problems ???
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18832737
>Leaving an UNDEFINED variable can cause me security problems ???
not that I know of, but I am not the (php/net) security guy/specialist
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
str_replace not working in php script 4 30
hasing a url 16 28
Download tables into separate sheets 3 27
how to use a switch statement with heredoc 11 23
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question