$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");

2024-12-21 14:44:45
推荐回答(1个)
回答1:

好吧,变量你自己定义好,用别的方法传进去也行,自己写连接函数,无非是两个PHP函数
mysql_connect做连接用
还一个是mysql_select_db用来选库
// set database server access variables:
$host = "XXX.XXX.XXX.XXX"; //ip或者主机名
$user = "xxx"; //用户名
$pass = "xxx"; //密码
$db = "xxx"; //数据库名

// open connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");

// select database
mysql_select_db($db) or die ("Unable to select database!");