I want to use $_GET to fetch error messages from an array.

Heres my array:

$errormessages = array(
    'nosearch'  => 'Your search returned no results - <a href="guide?t=search">Click Here For Search Tips</a>',
    '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 :)

use this echo $errormessages ['nosearch']; instead of $_GET['nosearch']; If my answer is not reached your question, be more clear...

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 :)

you are right...
then why don't you use swith case in if loop...
then try like this...

if(!empty($_GET['err'])){
    switch($_GET['err']){
        case 'nosearch' : $msg="Your search returned no results - <a href="guide?t=search">Click Here For Search Tips</a> ";
        break;
    .......and so on
    }
}

then you have to pass your url like

?err=nosearch

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?

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....

Oh sorry, I misunderstood it. Thank you :)

EDIT: Got it set up really nicely now. Works great :D

Ok...Welcome....

commented: Thanks :) +2
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.