I everybody, ive coded a script recently seems to be good but when i go to my page on on localhost, ive an error like this:
Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /srv/http/index.php:11 Stack trace: #0 {main} thrown in /srv/http/index.php on line 11
<?php
error_reporting(E_ALL); ini_set('display_errors', 1);
$db_hostname = '127.0.0.1';
$db_username = 'root';
$db_password = 'mypass';
$db_database = 'my database name';
$connect = mysql_connect("$db_hostname","$db_username","$db_password");
if (!$connect)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db($db_database) or die ("could not find db");
$output ='';
if (isset ($_POST['search'])){
$search = $_POST['search'];
}
$query = mysql_query("SELECT * FROM user WHERE email LIKE '%".$search."%'" ) or die("could not search");
$count = mysql_num_rows($query);
if($count == 0){
$output = 'There was no search results !';
}
else{
while($row = mysql_fetch_array($query)){
$fname = $row['search];
$output .='<div> '.$fname.'</div>';
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=utf-8" />
<title>Lookup</title>
</head>
<body>
<form action="index.php" method="post">
<input type="text" placeholder="search" name="search">
<input type="submit" value=">>"/>
</form>
<?php
print("$output");
?>
</body>
</html>