您的位置:宽带测速网 > 网络知识 > 如何通过网站调用mysql数据库

如何通过网站调用mysql数据库

2025-06-17 10:23来源:互联网 [ ]

PHP网站调用mysql数据库的方法

1.连接数据库

$con = mysql_connect("localhost","peter","abc123");

if (!$con)

{

die('Could not connect: ' . mysql_error());

}

// some code

?>

2.使用mysql_select_db()函数选择数据库

mysql_select_db("school",$con)

3.使用mysql_query()函数即可调用mysql数据库中的数据

#result = mysql_query("select * form teacher");