Solved

error_reporting(E_ALL)......

Posted on 2007-03-31
6
351 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]
Comment Utility
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
Comment Utility
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
Comment Utility
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
Easy Project Management (No User Manual Required)

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
Comment Utility
>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
Comment Utility
Thnx angelIII.....
One last Question..
Leaving an UNDEFINED variable can cause me security problems ???
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
>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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to count occurrences of each item in an array.
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…

762 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

9 Experts available now in Live!

Get 1:1 Help Now