Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

error_reporting(E_ALL)......

Posted on 2007-03-31
6
Medium Priority
?
381 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 143

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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 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 143

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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.

688 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