PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Hi, could someone look at the bebelow code and help me fixing the error message?
I have a page with one text field to search and a php script to show the results.
and I get the following error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /usr/local/psa/home/vhosts/giustinianinicola.com/httpdocs/contacts/search.php on line 28
then I am understanding this wrong,
how can I say that whatever I am asking to serch for, in the html form, it has to seach in the entire database, in all columns,
and then show the entire row?
Hi,
who could help me checking what is wrong with the below SQL statement?
I am trying to tell the script to search the all databese for the string contained in the search field of the form called search.html.
I just can't make it work.
seriousdamage wrote:I am trying to tell the script to search the all databese for the string contained in the search field of the form called search.html.
That's not possible in the terms you are saying.
Making a search script is a lot more complicated then you realize, especially when you want to to match everything. Which I don't even think is advisable.
Sql Needs to know what to match, its not just going to guess and look in every table and column.
Below is a very simple search, matching one column in one table, returning all the data in the row.
$result = mysql_query("SELECT * FROM contacts where first_name LIKE '" . $_POST['search'] ."' OR last_name LIKE '" . $_POST['search'] ."' OR company_name LIKE '" . $_POST['search'] ."' OR website LIKE '" . $_POST['search'] ."' OR street LIKE '" . $_POST['search'] ."' OR city LIKE '" . $_POST['search'] ."' OR zip LIKE '" . $_POST['search'] ."' OR country LIKE '" . $_POST['search'] ."' OR mail1 LIKE '" . $_POST['search'] ."' OR mail2 LIKE '" . $_POST['search'] ."' OR phone LIKE '" . $_POST['search'] ."' OR mobile LIKE '" . $_POST['search'] ."' OR card LIKE '" . $_POST['search'] ."' OR birthday LIKE '" . $_POST['search'] ."'") or die (mysql_errno().": ".mysql_error()."<BR>");