dtrpv60860 2017-03-10 08:27
浏览 74
已采纳

连接到xampp数据库

Am trying to connect to a xampp server but its not working this is my code:

session_start();

define('DB_NAME', 'login');
define('DB_USER', 'root');
define('DB_PASSWORD', '');
define('DB_HOST', 'localhost');

$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);

if ($link) {
    die('Failed to connect: ' . mysql_error());
}
$db_select = mysql_select_db(DBNAME, $link);
if (!$db_select) {
    die('Failed to connect:' . DBNAME . ':' . mysql_error());
}
  • 写回答

2条回答 默认 最新

  • doulan9419 2017-03-10 08:31
    关注

    mysql is no longer usable. use mysqli and it will work fine

    If you want to know more about it visit https://www.w3schools.com/php/func_mysqli_query.asp

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?