简体   繁体   中英

Cannot connect to phpMyAdmin database using MAMP Server

I am trying to create a login system on my website but I can't connect the database to my server (Error: localhost is currently unable to handle this request. HTP ERROR 500). I am using MAMP server.

This is my code:

<?php

$host="localhost:3306";
$user="root";
$pass="root";

$db_name="MyDatabase";

mysqli_connect($host, $user, $pass) or die("Error in connecting to the mysql server!");
mysql_select_db($db_name) or die("Error in selecting the database!");

?>

Thanks.

Replace your last 2 lines by these:

$link = mysqli_connect($host, $user, $pass) or die("Error in connecting to the mysql server!");
mysqli_select_db($link, $db_name) or die("Error in selecting the database!");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM