入门例子php mysql中读取表中数据失败,求大侠指教
1.问题:用php读mysql中的一张表,怎么也读不出来,页面有时空白,有时有php中的一小节代码,苦调了一天了,求指导!感激不尽!!
2.mysql中,数据库:test;表名:apple;(字段:firstname,lastname)
3.index.php(试过连接数据库成功)
代码:
<br />
<html><br />
<head><br />
<title>php分页示例</title><br />
<meta http-equiv="content-Type" content="text/html; charset=utf-8"><br />
</head><br />
<br />
<body><br />
<?php<br />
$dbh = @mysql_connect("localhost","root","");<br />
if(!$dbh){die("error");}<br />
@mysql_select_db("test", $dbh);<br />
$sql = "SELECT * FROM apple";<br />
?><br />
<?<br />
$rs = mysql_query($sql, $dbh);<br />
while($row = mysql_fetch_array($rs)) <br />
echo $row[id];<br />
echo $row[name];<br />
echo '<br/>';<br />
?><br />
<?<br />
@mysql_close($dbh);<br />
?> <br />
<br />
<br />
</body><br />
</html> <br />
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号