cliftonbazaar Posted June 24, 2009 Share Posted June 24, 2009 I have a loop that gets a $_POST from the previous page which could be anything in the loop. Each time I run the code I get a warning about Notice: Undefined offset: 1 in C:\items.php on line 50 of each loop. FOR($i=1; $i<=10; $i++) { IF($_POST[$i]) { //There is something to be sold $items_array[$i]=$items_array[$i]-$_POST[$i]; $player['gold']=$player['gold']+($_POST[$i]*$i*10); } } Is there a piece of code I could write that checks to see if it is defined? Quote Link to comment https://forums.phpfreaks.com/topic/163467-solved-defining-_post/ Share on other sites More sharing options...
RussellReal Posted June 24, 2009 Share Posted June 24, 2009 its merely a notice.. do this: if (@$_POST[$i]) { } Quote Link to comment https://forums.phpfreaks.com/topic/163467-solved-defining-_post/#findComment-862508 Share on other sites More sharing options...
n1tr0b Posted June 24, 2009 Share Posted June 24, 2009 we have the same problem... but for now thx for the help... Quote Link to comment https://forums.phpfreaks.com/topic/163467-solved-defining-_post/#findComment-862517 Share on other sites More sharing options...
RussellReal Posted June 24, 2009 Share Posted June 24, 2009 OH I see what you did.. do this: foreach ($_POST as $k => $v) { // $v will hold the value of each element in POST 1 after the other } Quote Link to comment https://forums.phpfreaks.com/topic/163467-solved-defining-_post/#findComment-862519 Share on other sites More sharing options...
cliftonbazaar Posted June 24, 2009 Author Share Posted June 24, 2009 its merely a notice.. do this: if (@$_POST[$i]) { } This did the trick. Only one POST actually has a value so the other 9 are NULL. So what does @ actually do/mean? Quote Link to comment https://forums.phpfreaks.com/topic/163467-solved-defining-_post/#findComment-862525 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.