Solved

error_reporting(E_ALL)......

Posted on 2007-03-31
6
360 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 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 143

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 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

Title # Comments Views Activity
Email called spam 5 36
Need to remove %20 from url in get 17 36
Wordpress Pagination 1 28
form validation - make sure at least 1 checkbox is selected 18 27
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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…

840 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