Perhaps you could test the string length using strlen() and then if 0 dont issue the SQL statement rather a msg to the user. if((strlen($searchtext))>0){ issue sql }else{echo'enter a search string you stupid user';}, or you could use java scripts to validate the form 1st. brent "Anthony Ritter" <tony@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:20040421024247.10832.qmail@xxxxxxxxxxxxxxx > Greets, > The following code snippet receives data from a textbox named searchtext if > the user types in a word. > > It then tries to match that word from the mysql database using: > > $searchtext = $_POST['searchtext']; > if ($searchtext != '') { // Some search text was specified > $where .= " AND blurb LIKE '%$searchtext%'"; > } > > and adding on to the WHERE sql statement. > > If the user clicks the submit _without_ inserting a word, the whole database > is output due to the basic select sql statement of: > > $select = 'SELECT DISTINCT merch.ID, merch.blurb, merch.price'; > $from = ' FROM merch'; > $where = ' WHERE 1=1 '; > > I am trying to work out a way to display a page that might say - "Please > enter a word" if the user fails to insert a word in the textbox. > > Any help greatly appreciated. > TR > ................. > > > <?php > $dbcnx = mysql_connect('localhost', 'root', 'mypass'); > mysql_select_db('sitename'); > > // The basic SELECT statement > $select = 'SELECT DISTINCT merch.ID, merch.blurb, merch.price'; > $from = ' FROM merch'; > $where = ' WHERE 1=1 '; > > $lid = $_REQUEST['lid']; > if ($lid != '') { // An lot is selected > $where .= " AND lid='$lid'"; > } > > $searchtext = $_POST['searchtext']; > if ($searchtext != '') { // Some search text was specified > $where .= " AND blurb LIKE '%$searchtext%'"; > } > ?> > > <table border="1" align="center"> > <tr><th>Click for > details</th><th>Description</th><th>Price</th><th>Edit</th><th>Delete</th><t > h>Photo</th></tr> > > //etc............. -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php