I am making a PHP website through localhost, but I want to connect my site to a database. The method I found didn't work, even after looking at the new PDOs. How can I resolve this issue?
$username = "root";
$password = "password";
$server = "localhost";
$database = "";
$connect = mysql_connect($server, $username, $password);
mysql_query("SET NAMES UTF8");
if(!$connect) {
echo "Connection Error: " . mysql_errno();
exit();
}
$db = mysql_select_db($database);
if(!$database) {
echo "Database Error: " . mysql_error();
echo "";
echo "You can edit the database connection details in the connect.php file";
exit();
}
$username = "root";
$password = "password";
$server = "localhost";
$database = "";
$connect = mysql_connect($server, $username, $password);
mysql_query("SET NAMES UTF8");
if(!$connect) {
echo "Connection Error: " . mysql_errno();
exit();
}
$db = mysql_select_db($database);
if(!$database) {
echo "Database Error: " . mysql_error();
echo "";
echo "You can edit the database connection details in the connect.php file";
exit();
}