致命错误:未捕获错误:调用未定义的函数 C:\ xampp \ htdocs \ oes3 \ exam \ includes \ config.php中的mysql_connect()13
" <?php
//START THE SESSION
session_start();
//GLOBAL VARIABLES
define('DB_HOST','localhost');
define('DB_USER','root');
define('DB_PASS','');
define('DB_NAME','exam');
//FUNCTION TO CONNECT DATABASE
if(!mysql_connect(DB_HOST,DB_USER,DB_PASS))
die('Could not connect : '.mysql_error());
//FUNCTION TO SELECT THE DATABASE
if(!mysql_select_db(DB_NAME))
die('Could not select database : '.mysql_error());
?>"
答案 0 :(得分:0)
尝试使用
$con = mysqli_connect("localhost","root","","test");
答案 1 :(得分:0)
尝试mysqli_connect而不是mysql_connect。并使用mysqli更新其他方法。请尝试以下代码
$con=mysqli_connect(DB_HOST,DB_USER,DB_PASS);
if(!$con)
die('Could not connect : '.mysqli_connect_error());
//FUNCTION TO SELECT THE DATABASE
if(!mysqli_select_db($con,DB_NAME))
die('Could not select database');
答案 2 :(得分:-1)
在xammp servre中安装mysql包。否则你可以使用mysqli进行数据库连接。下面的代码用于连接mysqli oops和过程。
$conn = new mysqli (HOSTNAME,USERNAME,PASSWORD,DATABASE);
OR
$conn = mysqli_connect(HOSTNAME,USERNAME,PASSWORD);