I have a page which uses the PDO method to pull results from a database.
I tried adding a search form and everything looks good.
But when I submit the form I get
Notice : Undefined variable: pdo in C:\xampp\htdocs\DCT\2\racks\index.php on line 73
Heres the PHP which im using
if(isset($_GET['Search'])) {
$search = strtolower($_GET['Search']);
preg_replace("#[^0-9a-z]#i","",$search);
$query = 'SELECT rack_id,title,room_id,row,bay
FROM racks
WHERE title LIKE "%'.$search.'%"';
$result2 = $pdo->query($query);
}
The pdo variable seems to work fine at the beginning
$result = $pdo->query($sql);
can I not use it again?