943,693 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 3152
  • PHP RSS
Mar 2nd, 2009
0

$_GET['Array Values']

Expand Post »
I want to use $_GET['error'] to fetch error messages from an array.

Heres my array:
php Syntax (Toggle Plain Text)
  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.
Similar Threads
Reputation Points: 11
Solved Threads: 2
Junior Poster
!Unreal is offline Offline
112 posts
since Dec 2007
Mar 2nd, 2009
0

Re: $_GET['Array Values']

use this echo $errormessages ['nosearch']; instead of $_GET['nosearch']; If my answer is not reached your question, be more clear...
Last edited by Shanti C; Mar 2nd, 2009 at 4:52 am.
Reputation Points: 137
Solved Threads: 162
Posting Virtuoso
Shanti C is offline Offline
1,641 posts
since Jul 2008
Mar 2nd, 2009
0

Re: $_GET['Array Values']

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
Reputation Points: 11
Solved Threads: 2
Junior Poster
!Unreal is offline Offline
112 posts
since Dec 2007
Mar 2nd, 2009
0

Re: $_GET['Array Values']

you are right...
then why don't you use swith case in if loop...
then try like this...
PHP Syntax (Toggle Plain Text)
  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 C; Mar 2nd, 2009 at 5:24 am.
Reputation Points: 137
Solved Threads: 162
Posting Virtuoso
Shanti C is offline Offline
1,641 posts
since Jul 2008
Mar 2nd, 2009
0

Re: $_GET['Array Values']

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?
Reputation Points: 11
Solved Threads: 2
Junior Poster
!Unreal is offline Offline
112 posts
since Dec 2007
Mar 2nd, 2009
0

Re: $_GET['Array Values']

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....
Reputation Points: 137
Solved Threads: 162
Posting Virtuoso
Shanti C is offline Offline
1,641 posts
since Jul 2008
Mar 2nd, 2009
0

Re: $_GET['Array Values']

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.
Reputation Points: 11
Solved Threads: 2
Junior Poster
!Unreal is offline Offline
112 posts
since Dec 2007
Mar 2nd, 2009
1

Re: $_GET['Array Values']

Ok...Welcome....
Reputation Points: 137
Solved Threads: 162
Posting Virtuoso
Shanti C is offline Offline
1,641 posts
since Jul 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: help me, please
Next Thread in PHP Forum Timeline: Creating a 6 digit number from letters





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC