Re: php mysql search
Re the code: first, every mysqli API call to the database that can raise an error needs error trapping, eg minimally ...
$connect = mysqli_connect(...) or exit( mysqli_connect_error() );
...
$result = mysqli_query(...) or exit( mysqli_error($connect) );
And all data harvested from $_GET[] and $_POST[] needs to be sql-injection-proofed with mysqli_escape_string().
Re the query call: there are 4 possible outcomes (i) it errors out (ii) it retrieves one matching row (iii) it finds multiple matching rows, (iv) it finds no matching row. Your code covers only 2 of the 4 possibilities. Code for all possibilities, add a $debug var, set it true till no more bugs are found, insert code to display all relevant variable values so you can track what's happening.
Subject
Written By
Posted
Re: php mysql search
May 20, 2018 10:32AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.