Search Webmaster Help and Solution

Using * char in my search engine (was: Why wont this work?)

Ive created a search function for my site, but there something weird happening. When I enter the character "*" in the search form, then I get a script error message. When I enter something else, then it appears to be working fine.

I wont post the whole code here, but a short version of the code. Take a look at the following code:

Code: <? $search = "*"; $text = "This is a **** test!"; if (eregi($search, $text)) {$found = "FOUND";} else {$found = "NOT FOUND";} echo $found; ?>

If you run this code, then you will get an error message. But if you replace $search = "*" with $search = "is", then it will work!

What is the problem here? Ive created a search function for my site, but there something weird happening. When I enter the character "*" in the search form, then I get a script error message. When I enter something else, then it appears to be working fine.

I wont post the whole code here, but a short version of the code. Take a look at the following code:

Code: <? $search = "*"; $text = "This is a **** test!"; if (eregi($search, $text)) {$found = "FOUND";} else {$found = "NOT FOUND";} echo $found; ?>

If you run this code, then you will get an error message. But if you replace $search = "*" with $search = "is", then it will work!

What is the problem here?

View Complete Thread with Replies

Related Items

Query failed: connection to localhost:3354 failed (errno=111, msg=Connection refused).