NextGenForum.net Posted November 8, 2007 Share Posted November 8, 2007 The code below is a search form, that i have found on the web, the bolded lines are producing errors, www.selectgreen.co.uk/search.php Search for company. Any help, im hoping its ok apart from those problems Thanks <? //This is only displayed if they have submitted the form if ($searching =="yes") { echo "<h2>Results</h2><p>"; //If they did not enter a search term we give them an error if ($find == "") { echo "<p>You forgot to enter a search term"; exit; } // Otherwise we connect to our Database mysql_connect("localhost", "user", "password") or die(mysql_error()); mysql_select_db("databse") or die(mysql_error()); // We preform a bit of filtering $find = strtoupper($find); $find = strip_tags($find); $find = trim ($find); //Now we search for our search term, in the field the user specified $data = mysql_query("SELECT * FROM property WHERE upper($field) LIKE'%$find%'"); //And we display the results <b>while($result = mysql_fetch_array( $data ))</b> { echo $result['fname']; echo " "; echo $result['lname']; echo "<br>"; echo $result['info']; echo "<br>"; echo "<br>"; } //This counts the number or results - and if there wasn't any it gives them a little message explaining that <b>$anymatches=mysql_num_rows($data);</b> if ($anymatches == 0) { echo "Sorry, but we can not find an entry to match your query<br><br>"; } //And we remind them what they searched for echo "<b>Searched For:</b> " .$find; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/76567-search-form-errors-code-included/ Share on other sites More sharing options...
NextGenForum.net Posted November 8, 2007 Author Share Posted November 8, 2007 Sorry i think my servers down so cant view link Quote Link to comment https://forums.phpfreaks.com/topic/76567-search-form-errors-code-included/#findComment-387756 Share on other sites More sharing options...
fenway Posted November 8, 2007 Share Posted November 8, 2007 What error? What query? Quote Link to comment https://forums.phpfreaks.com/topic/76567-search-form-errors-code-included/#findComment-387810 Share on other sites More sharing options...
NextGenForum.net Posted November 8, 2007 Author Share Posted November 8, 2007 You need to search by using the link searcg company and the lines are bolded in this thread Thankjs Quote Link to comment https://forums.phpfreaks.com/topic/76567-search-form-errors-code-included/#findComment-387811 Share on other sites More sharing options...
fenway Posted November 8, 2007 Share Posted November 8, 2007 You need to search by using the link searcg company and the lines are bolded in this thread Thankjs I don't need to search by anything -- YOU need to post the error. And you can't bold inside a code block (which I changed to make it more readable). Besides, you put mysql functions in bold -- it's because whatever you're doing isn't a valid query. Quote Link to comment https://forums.phpfreaks.com/topic/76567-search-form-errors-code-included/#findComment-387814 Share on other sites More sharing options...
NextGenForum.net Posted November 8, 2007 Author Share Posted November 8, 2007 <code>Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/nextgen/public_html/search.php on line 236 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/nextgen/public_html/search.php on line 248 Sorry, but we can not find an entry to match your query</code> These are the erroes thats i get after searching i hope thats what you need Thanks Also what do you put to get code boxes on the forums Quote Link to comment https://forums.phpfreaks.com/topic/76567-search-form-errors-code-included/#findComment-387815 Share on other sites More sharing options...
fenway Posted November 8, 2007 Share Posted November 8, 2007 <code>Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/nextgen/public_html/search.php on line 236 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/nextgen/public_html/search.php on line 248 Sorry, but we can not find an entry to match your query</code> These are the erroes thats i get after searching i hope thats what you need Thanks Also what do you put to get code boxes on the forums [ code ] and [ / code ] -- without the spaces Very good -- now, what's the mysql statement? And please don't post the php line... I want to see an SQL statement. WAIT -- you're missing a space after LIKE. BUT STILL -- don't post about mysql errors without posting a mysql statment! This is very clearly stated in the forum guidline. Quote Link to comment https://forums.phpfreaks.com/topic/76567-search-form-errors-code-included/#findComment-387817 Share on other sites More sharing options...
NextGenForum.net Posted November 8, 2007 Author Share Posted November 8, 2007 So i need to put a spacee after like? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/76567-search-form-errors-code-included/#findComment-387819 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.