Solved

error_reporting(E_ALL)......

Posted on 2007-03-31
6
357 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 Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Please show me easiest post form. 3 31
.php tree directory? 5 56
updating the date data 12 23
Why my select dropdown does not work? 8 26
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

920 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now