代码示例:
<?php
$con = mysql_connect("localhost", "hello", "321");
if (!$con)
{
die('Could not connect: ' . mysql_error());//这里也可以直接写成:or die('...........')不需要if判断
}
$db_selected = mysql_select_db("test_db",$con);
$sql = "SELECT * from Person WHERE Lastname='Adams'";
$result = mysql_query($sql,$con);
print_r(mysql_fetch_assoc($result));
mysql_close($con);
?>
输出:Array
(
[LastName] => Adams
[FirstName] => John
[City] => London
)
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!