Jump to content

Recommended Posts

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;
}
?>

Link to comment
https://forums.phpfreaks.com/topic/76567-search-form-errors-code-included/
Share on other sites

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.

<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>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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.