<?php
/* Database config /
$db_host = 'localhost';
$db_user = 'root';
$db_pass = '';
$db_database = 'f16';
/
End config */
$mysqli = new mysqli($db_host, $db_user, $db_pass, $db_database)
// collect

if(isset($POST['search'])) {
$searchq = $
POST['search'];
$searchq = perg_replace("#[0-9a-z]#i", "", $searchq);


$query  = mysql_query("SELECT * FROM student WHERE Name LIKE  '%$searchq%' OR Address LIKE '%$searchq%'") OR die("could not search");

$count = mysql_num_rows($query);

if($count == 0) {
    $output = 'There was no search result!';
} else {
    while ($row = mysql_fetch_array($query))  {
        
        $ame = $row['Name'];
        $id = $row['ID number'];
        $address = $row['Address'];
        
        $output .= '<div>' .$fname.' '.$address.'</div>';
    }
}

}

?>
<!DOCTYPE html>
<html>
<head>
<title>Search</title>
</head>
<body>

<form action="f1.php" method="post">
<input type="text" name="search" placeholdr="Enter name">
<input type="submit" value=">>">
</form>
<?php print ("$output");?>

</body>
</html>

    Have you error_reporting E_ALL?
    What errors report do you get?

      For starters, perg_replace is not a function. Try preg_replace instead. Second, your script is vunerable to SQL Injection

        where is the mistake

        The mistake is using dangerous obsolete mysql_* code that has been completely removed from Php. You need to use PDO with Prepared Statements

        This tutorial will get you going.
        https://phpdelusions.net/pdo

          5 days later
          1. You lack a semicolon after your connection string:
            //corrected
            $mysqli = new mysqli($db_host, $db_user, $db_pass, $db_database);

          2. As Sneakyimp noted above, you've misspelled "preg" in the function "preg_replace()".

          3. You've incorrectly named one variable; you have $ame in the assignment statement in the while loop but you place $fname inside the $output string. I would change $ame to $fname.

            Write a Reply...