Mysql和php db连接[重复]

This question already has an answer here:

<?php

mysql_connect("localhost","root","");

mysql_select_db("univ_management");

?>

this is the following block of the code

Uncaught Error: Call to undefined function mysql_connect() in C:\xampp\htdocs\ums4\db_con.php:2 Stack trace: #0 C:\xampp\htdocs\ums4\action.php(10): include_once() #1 {main} thrown in C:\xampp\htdocs\ums4\db_con.php on line 2

</div>

First and foremost: do not use mysql_* functions. Just don't, there is no excuse. These have long since been deprecated (with good reason). Instead, use the mysqli_* functions (note the i) or the PDO library. With that out of the way, an actual answer to your question:

Though dense, the error message describes exactly the problem:

... Call to undefined function mysql_connect() ...

This implies that PHP is missing the appropriate shared library that might define that function. Given the currently supported versions of PHP, I suspect you are using PHP7+. This is important because the mysql_* functions were removed in PHP v7.0.0.