connect . php title >
head >
/* PHP手册中的PHP连接Mysql的实例 */
php
/* 连接选择数据库 */
$link = mysql_connect ( " mysql_host " , " mysql_user " , " mysql_password " ) or die ( " Could not connect " );
print " Connected successfully " ;
mysql_select_db ( " my_database " ) or die ( " Could not select database " );
/* 执行 SQL 查询 */
$query = " SELECT * FROM my_table " ;
$result = mysql_query ( $query ) or die ( " Query failed " );
/* 在 HTML 中打印结果 */
print "
$col_value | \n " ;