I started learning PHP and decided to try and make a forum out of what I knew. I never really got to connect to MySQL database through PHP I was just wondering why it is giving me this error:
Fatal error: Uncaught Error: Call to undefined function mysql_connect() in
C:\xampp\htdocs\FORUM\connect.php:9 Stack trace: #0
{main} thrown in C:\xampp\htdocs\FORUM\connect.php on line 9
I do recognise that it says that I have an undefined function, but I dont know how to define mysql_connect(). I am hoping that someone can have a look at my code and tell me how to fix my (most likely blatant) error.
<?php
$database = array();
$database['host'] = "localhost";
$database['port'] = '3306';
$database['name'] = "forum";
$database['username'] = "root";
$database['password'] = "";
$link = mysql_connect($database['host'], $database['username'], $database['password']);
if ($link) {
echo "Successfully connected to the database : ".$database['name'];
} else {
echo "Connect to the database : ".$database['name'] . "failed<br/>";
echo "Error : ".mysql_error();
}
?>