Hi
echo $query; echo mysql_error( $mysql_db_link); is useful for finding query errors (it echos the query itself, and any error message) but the problem here I think is that you are using 'date' as a field name and/or variable name. Try using a name which is not a reserved word. HTH Peter > -----Original Message----- > From: Jason [mailto:[EMAIL PROTECTED]] > Sent: 23 October 2001 22:52 > To: [EMAIL PROTECTED] > Subject: [PHP-DB] PHP form to search MySQL DB > > > Ok here is my problem... I have a form on a page named index.php and the > code for the form is as follows: > > <form name="auth" method="post" action="search01.php"> > <p>*I.E. - Format is 04/01/2001*</p> > <p>Search for Ads by date: > <input type="text" name="date"> > </p> > <p> > <input type="submit" name="login" value="Submit"> > <input type="reset" name="reset" value="Reset"> > </p> > </form> > > This form is used to supply the variable that we would like to seach the > database by. I.E. by date in this case. The php script that > connects to the > database and performs the search is in a file named search01.php. And the > php script is as follows: > > <?php > mysql_connect ("db_hostname", "db_username", "db_password"); > > mysql_select_db ("db_name"); > > if ($date == "") > {$date = '%';} > > $result = mysql_query ("SELECT > fname,lname,address,city,state,zip,phonea,phone,email,crty,crnum,c > rmo,cryr,w > eeks,ogden,rock,logan,ipaddress,ad,total,num,date,time > FROM ads WHERE date LIKE '%$date%' LIMIT 0, 30 "); > > $count = mysql_num_rows($result); > > if (mysql_num_rows($result) ) > { > while( $row = mysql_fetch_array($result) ) > { > > print "<B>Name: </B>".$row['fname'].", ".$row[' lname']."<BR>\n"; > print "<B>Date: </B>".$row['date']."<BR>\n"; > } > } > else { > print "No rows found";} > ?> > > Ok now that I have the form and the search script in place > and as I test > it out I recieve an error message on 2 lines regardless of the > format of the > date I use (i.e. 10/23/2001, %23%, 2001-23-10, etc.) The error > messages are > as follows: > > Warning: 0 is not a MySQL result index in search01.php on line 141 > > Warning: 0 is not a MySQL result index in search01.php on line 143 > No rows found > > Now that we have the background info out of the way I am wondering what > these error messages mean and how to resolve them. I have been using a > couple of books as reference when creating this seach page but they do not > cover using a form to pass a variable to a php script for use withing a > select statement against a database. If anyone has any ideas, suggestions > or otherwise please let me know because I would love to get this script > finished and posted somewhere. Thanks again. > Jason > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]