Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

$_GET and $_POST errors

Status
Not open for further replies.

jimbobiv

IS-IT--Management
Nov 18, 2004
16
GB
How can i hide these errors,

for example:

$name = $_POST['name'];
$primary = $_POST['Primary'] ;
if ($primary=='') $primary='OFF';
$alliance = $_POST['Alliance'] ;
if ($alliance=='') $alliance='OFF';
$tournament = $_POST['Tournament'] ;
if ($tournament=='') $tournament='OFF';
$limited = $_POST['Limited'] ;
if ($limited=='') $limited='OFF';
$FFA = $_POST['FFA'] ;
if ($FFA=='') $FFA='OFF';

There is my code, $name is always entered so i dont need to check for it, all the others are information for check boxes (checked or unchecked) if unchecked there is no information, so how do i stop the annoying error coming up when the PHP tries to retrieve info from the POST taht doesnt exist... i have tried

(if $_POST['FFA']) $FFA=$_POST['FFA'];

but i get the same errors.. is there a way of either storing the errors as a variable (and then ignoring them) or perhaps telling the $_POST command not to return errors?

Cheers guys (and gals)

James
 
I'm assuming you mean php says stuff like non existent index or something. When you submit a problem give as a clue !.
I reckon though you need to look at the function isset()
 
POST is not a command, it's a superglobal array.

What I believe you actually want is to know if a specific array key exists
Or as ingresman suggested, you could also check to see if the particular value isset
And just for fun, the actual question you asked, is one I always hesitate to answer... but you can hide the errors using the @ operator, but you almost certainlly don't want this, you can read why here
 
cheers, and to ingresman, its obvious what the fault would be from the code i showed... sorry if i didnt explain it properly but like

i=3 i get an error, well der u missed a dollar, dont need to put what the error is ;o)

anyways, i'll read those articles when i have a second!
 
Hi,

This would work just fine :

Code:
$FAA = $_REQUEST["FAA"];
if(!$FAA)
  $FAA = "OFF";

Regards


Jakob
 
You need to be careful. If $FAA exists but has a legitimate value of zero, PHP will in examining !$FAA convert the value to FALSE. This could lead to unexpected behavior from the script.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Also, don't use $_REQUEST. It has some of the same security problems that you can have with setting register_globals to "on". Be specific -- use $_GET, $_POST, $_SERVER, $_COOKIE, $_SESSION as they are the most specific.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
I have already found that problem, with the 0 value thing, thats why im not using that, i have solved the problem using the isset rule, thanks guys...
 
Sorry, I've been doing PHP for so long I never assume anything !even when a couple of lines of code are presented rather than the actual error.
ho hum
 
lol fair enuff, still prob solved so all done now ;o)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top