Forums

This topic is locked

code snippet from search text box

Posted 08 Dec 2004 19:55:42
1
has voted
08 Dec 2004 19:55:42 Simon Wantling posted:
Hi,
I have been setting a dynamic website in dreamweaver which allow users to search a database for insect species by entering a keyword in a text box. This is working fine but if the search button is pressed with an empty text box then the entire contents of the database are listed. I have tried to add a command to make the user enter at least two characters, but this still doesn't work. In fact is doesn't list anything now. The code snippet is as follows.
$colname_speciesdata = "";
if (!isset($_GET['species'])) $_GET['species']='';
if (strlen($_GET['species']) <2) {
echo "error";
} else{
$colname_speciesdata = (get_magic_quotes_gpc()) ? $_GET['species'] : addslashes($_GET['species']);
}
If someone could help me out with any ideas then I would be very grateful. I am no php expert !!

Many Thanks
Simon

Replies

Replied 10 Dec 2004 20:16:04
10 Dec 2004 20:16:04 Chris Charlton replied:
Seems like this might have been more of a SQL issue - resolution should be at <a href="www.dmxzone.com/forum/topic.asp?TOPIC_ID=30226&FORUM_ID=3&CAT_ID=2&Topic_Title=Search+and+list+boxes&Forum_Title=Dreamweaver+UltraDev">Search and list boxes forum post</a>.

Reply to this topic