Im running a LAMP server and im trying to show on the webpage the table of my database
This is my php script
$servername = "127.0.0.1";
$username = "root";
$password = "none";
$dbname = "chegada";
$conn = mysqli_connect($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}else{echo "OK!";}
$sql = "SHOW TABLES FROM $dbname";
$result = mysql_query($sql);
if (!$result) {
echo "DB Error, could not list tables
";
echo 'MySQL Error: ' . mysql_error();
exit;
}
And the webpage shows this
Warning: mysqli_connect(): (HY000/2002): Connection refused in /var/www/html/index.php on line 16
Notice: Trying to get property of non-object in /var/www/html/index.php on line 17
OK!
Fatal error: Uncaught Error: Call to undefined function mysql_query() in /var/www/html/index.php:22 Stack trace: #0 {main} thrown in /var/www/html/index.php on line 22
can someone help me out with this?