Undefined Variables = BLEH
Posted: Fri Aug 30, 2002 5:36 pm
I changed my php.ini file to display all errors
Basically I'm making a page that displays results 20 at a time and its working fine, however I keep getting UNDEFINED VARIABLES, UNDEFINED INDEX because when they first call the page these vars don't exist.
When I load it up to my server it looks fine because they have the simple errors turned off, but on my local machine it bugs me.
The easy thing to do is to lower my level checking in php.ini BUT is that the best thing? Shouldn't I write scripts with 0 errors at all or is this part of what we have to do?
I could also write a ton of if/else statements to check for values, is that the only way to have error free coding?
GIVES ERRORS:
DOESNT GIVE ERRORS
what do you guys usally do for your variables?
Basically I'm making a page that displays results 20 at a time and its working fine, however I keep getting UNDEFINED VARIABLES, UNDEFINED INDEX because when they first call the page these vars don't exist.
When I load it up to my server it looks fine because they have the simple errors turned off, but on my local machine it bugs me.
The easy thing to do is to lower my level checking in php.ini BUT is that the best thing? Shouldn't I write scripts with 0 errors at all or is this part of what we have to do?
I could also write a ton of if/else statements to check for values, is that the only way to have error free coding?
GIVES ERRORS:
Code: Select all
<?php
$page = $_REQUESTї'page'];
$query = $_POSTї'query'];
?>DOESNT GIVE ERRORS
Code: Select all
<?php
if(isset($_REQUESTї'page']))
{
$page = $_REQUESTї'page'];
}
if(isset($_POSTї'query']))
{
$query = $_POSTї'query'];
}
?>what do you guys usally do for your variables?