代码如下:<?php
/*
* Created on 2012-1-1
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
$conn = mysql_connect("localhost","root","") or die ("连接出错");
mysql_select_db("dongxinb",$conn); $sql="SELECT * FROM 'word'";
$query=mysql_query($sql,$conn);
$row=mysql_fetch_array($query);
echo $row[name];
?>其中name为dongxinb数据库word表的字段。
错误信息:Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\wamp\www\word\1.php on line 13其中INSERT能正常插入。
/*
* Created on 2012-1-1
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
$conn = mysql_connect("localhost","root","") or die ("连接出错");
mysql_select_db("dongxinb",$conn); $sql="SELECT * FROM 'word'";
$query=mysql_query($sql,$conn);
$row=mysql_fetch_array($query);
echo $row[name];
?>其中name为dongxinb数据库word表的字段。
错误信息:Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\wamp\www\word\1.php on line 13其中INSERT能正常插入。
解决方案 »
- mysql分页问题?怎么 求出ceil($count/$num)中的 $count ?
- failed to open stream windows2003 IIS + php 环境问题
- 请问,通常页面的浏览履历是如何制作的
- 如何加一个 soap request的header
- php 大菜求助
- 有将mysql数据表自动转成建表PHP源代码建表的工具吗?
- 问一个MYSQL语句,急呀急.
- 有数许nusoap的么?帮帮忙,急啊!
- [必读]应该用何种 php 服务器 性能比较好?
- 谁有win2000 server + apache 下的 php4.30 的配置文件
- apache 配置时候,phpinidir 这个选项是 apache其中的配置命令 还是php的命令。
- 连接虚拟机svn的问题
$sql="SELECT * FROM word";
/*
* Created on 2012-1-1
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
include("conn.php");?><table width=500 border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#add3ef">
<?
$sql="select * from word";
$query=mysql_query($sql);
while($row=mysql_fetch_array($query)){
?>
<tr bgcolor="#eff3ff">
<td>姓名:<? echo $row[name]?></td>
</tr>
<tr bgColor="#ffffff">
<td>Message:<?=$row[words]?></td>
<td>更新时间:<?=$row[date]?></td>
</tr><?
}
?></table>
那么这个哪里错了?
没有数据库的内容输出……很郁闷。INSERT也能用?
其中name date words都是字段。和刚才那段话同个数据库,上面删掉‘’之后可以输出了。
但是这个还是不能用……
这句话改成 <td>姓名:<?=$row[name]?></td>
...
no 大神,在看资料 偶尔回来刷新csdn 才看到还有问题.
</tr>
<tr bgColor="#ffffff">
<td>Message:<?php echo $row['words']; ?></td>
<td>更新时间:<?php echo $row['date']; ?></td>
改成这样吗?可是,问题照旧,没有输出。
print_r($row);
?>输出结果看看是什么.
conn.php 有没问题?
用INSERT语句都可以。
<?php
/*
* Created on 2012-1-1 To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
include ("conn.php");
?><table width=500 border="0" align="center" cellpadding="5"
cellspacing="1" bgcolor="#add3ef">
<?php
$sql = "select * from word";
$query = mysql_query ( $sql );
while ( $row = mysql_fetch_array ( $query ) ) {
echo <<<html
<tr bgcolor="#eff3ff">
<td>姓名:{$row['name']}</td>
</tr>
<tr bgColor="#ffffff">
<td>Message:{$row['words']}</td>
<td>更新时间:{$row['date']}</td>
</tr>
html;
}
?></table>
试看看是否正常,我已经测试过正常了。代码看起来不像有问题.