经测试代码如下:
/**
* 连接MysqL数据库,并简单查询
*
* @param
* @arrange (512.笔记) jb51.cc
**/
//create db connection
$connection = MysqL_connect("localhost","user","password");
if(!$connection)
{
die("Database connection Failed:" . MysqL_error());
}
// select a dtabase to use
$db_select = MysqL_select_db("database name",$connection);
if(!$db_select)
{
die("Database selection Failed:" . MysqL_error());
}
?>
<body>
$result = MysqL_query("SELECT * FROM tablename",$connection);
while ($row = MysqL_fetch_array($result))
{
echo $row["rownamehere"]." ".$row["rownamehere"]."<br/>";
}
?>
</body>
<?PHP
MysqL_close($connection);
?>
/*** 代码来自编程之家 jb51.cc(jb51.cc) ***/