$_GET['Array Values']

Thread Solved

Join Date: Dec 2007
Posts: 112
Reputation: !Unreal is an unknown quantity at this point 
Solved Threads: 2
!Unreal's Avatar
!Unreal !Unreal is offline Offline
Junior Poster

$_GET['Array Values']

 
0
  #1
Mar 2nd, 2009
I want to use $_GET['error'] to fetch error messages from an array.

Heres my array:
  1. $errormessages = array(
  2. 'nosearch' => 'Your search returned no results - <a href="guide?t=search">Click Here For Search Tips</a>',
  3. 'captcha' => 'The captcha you entered was incorrect, please try again.',);

So if I did echo $_GET['nosearch']; it would return Your search returned no results - <a href="guide?t=search">Click Here For Search Tips</a>
How can I do this?

Thanks
Last edited by !Unreal; Mar 2nd, 2009 at 4:44 am.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,076
Reputation: Shanti Chepuru is on a distinguished road 
Solved Threads: 98
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Veteran Poster

Re: $_GET['Array Values']

 
0
  #2
Mar 2nd, 2009
use this echo $errormessages ['nosearch']; instead of $_GET['nosearch']; If my answer is not reached your question, be more clear...
Last edited by Shanti Chepuru; Mar 2nd, 2009 at 4:52 am.
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 112
Reputation: !Unreal is an unknown quantity at this point 
Solved Threads: 2
!Unreal's Avatar
!Unreal !Unreal is offline Offline
Junior Poster

Re: $_GET['Array Values']

 
0
  #3
Mar 2nd, 2009
I wanted to use it in the URL. Because I need to redirect users then show the error message. You know?

So I redirect them to page.php?error=nosearch and then the no search error would show up
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,076
Reputation: Shanti Chepuru is on a distinguished road 
Solved Threads: 98
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Veteran Poster

Re: $_GET['Array Values']

 
0
  #4
Mar 2nd, 2009
you are right...
then why don't you use swith case in if loop...
then try like this...
  1. if(!empty($_GET['err'])){
  2. switch($_GET['err']){
  3. case 'nosearch' : $msg="Your search returned no results - <a href="guide?t=search">Click Here For Search Tips</a> ";
  4. break;
  5. .......and so on
  6. }
  7. }
then you have to pass your url like ?err=nosearch [/icode]
Last edited by Shanti Chepuru; Mar 2nd, 2009 at 5:24 am.
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 112
Reputation: !Unreal is an unknown quantity at this point 
Solved Threads: 2
!Unreal's Avatar
!Unreal !Unreal is offline Offline
Junior Poster

Re: $_GET['Array Values']

 
0
  #5
Mar 2nd, 2009
Hmm...thats not quite as useable as I would hope.

Is there a way to do it how I want to or is it not possible?
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,076
Reputation: Shanti Chepuru is on a distinguished road 
Solved Threads: 98
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Veteran Poster

Re: $_GET['Array Values']

 
0
  #6
Mar 2nd, 2009
I think the above is very simple method...
hmmmm...
another method is , you have use session arrays....
But above method.....No need to worry about anything else....
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 112
Reputation: !Unreal is an unknown quantity at this point 
Solved Threads: 2
!Unreal's Avatar
!Unreal !Unreal is offline Offline
Junior Poster

Re: $_GET['Array Values']

 
0
  #7
Mar 2nd, 2009
Oh sorry, I misunderstood it. Thank you

EDIT: Got it set up really nicely now. Works great
Last edited by !Unreal; Mar 2nd, 2009 at 6:15 am.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,076
Reputation: Shanti Chepuru is on a distinguished road 
Solved Threads: 98
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Veteran Poster

Re: $_GET['Array Values']

 
1
  #8
Mar 2nd, 2009
Ok...Welcome....
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 1239 | Replies: 7
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC