Hi all,
I'v table called vehicles with id (int auto_increment) and plate_number (varchar 150).
the plate_number have records like (a a a 1 1 1 1) (b b b 2 2 2 2), three chars and four numbers spliced by spaces.
I'v php search page with url like this:
http://localhost/vehicles/show.php?plate_number=f%20f%20f%205%205%205%205
search about plate_numbet = f f f 5 5 5 5
my php code:
// pdo connection.
// first sql test
$sql = "SELECT * FROM vehicles WHERE plate_number LIKE '%".$_GET['plate_number']."%'";
// second sql test
// $sql = "SELECT * FROM vehicles WHERE plate_number = '".$_GET['plate_number']."'";
$db->query($sql);
if($db->rowcount() > 0){
// print all results...
}else{
echo "There are no results.";
}
The query result is: There are no results..
But, when I copy the sql statements into phpmyadmin it is works fine. (there is a result). like this:
SELECT * FROM vehicles WHERE plate_number LIKE '%f f f 5 5 5 5%';
OR
SELECT * FROM vehicles WHERE plate_number = 'f f f 5 5 5 5';
Also i used string functions (htmlspecialchars, rawurldecode, ... ), still not work.
any suggestion to solve this issue?
Thanks to all