小弟初学PHP,编一个BLOG
然后出现如下错误,甚是迷糊,可能是我PHPADMIN用的不太明白,请指教!Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in D:\PHPnowV1.5\PHPnow\PHPnow-1.5.4\htdocs\sites\blogtastic\index.php on line 10<?php
require("header.php");$sql="select entries.*,categories.cat FROM entries,categories
where entries.cat_id=categories.id
ORDER BY dateposted DESC
LIMIT 1;";
$result = mysql_query($sql); $row = mysql_fetch_assoc($result);echo "<h2><a href='viewentry.php?id=".$row['id']."'>".$row['subject']."</a></h2><br/>";
echo "<i>In<a href='viewcat.php?id=".$row['cat_id']."'>".$row['cat']."</a>-Posted on".date("D jS F Y g.iA",strtotime($row['dateposted']))."</i>";
echo "<p>";
echo nl2br($row['body']);
echo "</p>";
require("footer.php");
?>以上是这个一面的源代码,帮我看看,谢谢啦~
然后出现如下错误,甚是迷糊,可能是我PHPADMIN用的不太明白,请指教!Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in D:\PHPnowV1.5\PHPnow\PHPnow-1.5.4\htdocs\sites\blogtastic\index.php on line 10<?php
require("header.php");$sql="select entries.*,categories.cat FROM entries,categories
where entries.cat_id=categories.id
ORDER BY dateposted DESC
LIMIT 1;";
$result = mysql_query($sql); $row = mysql_fetch_assoc($result);echo "<h2><a href='viewentry.php?id=".$row['id']."'>".$row['subject']."</a></h2><br/>";
echo "<i>In<a href='viewcat.php?id=".$row['cat_id']."'>".$row['cat']."</a>-Posted on".date("D jS F Y g.iA",strtotime($row['dateposted']))."</i>";
echo "<p>";
echo nl2br($row['body']);
echo "</p>";
require("footer.php");
?>以上是这个一面的源代码,帮我看看,谢谢啦~
解决方案 »
- 关于下拉框问题,
- Linux 下mkdir() 函数出现问题!
- 相关文章算法 配合tag
- 这样的一个Webservice应该如何调用呢?
- 本地机器上可以使用exec()函数,但是到了服务器上就不能执行该函数
- 求一个正则表达式
- php+sqlserver读取image类型图片,大于4K的图片如何显示
- odbc_fetch_row无效是什么缘故啊
- php4.2.3配置支持SQL Server2000?
- 各位大虾,把你们的项目要求和价格说一下,各位菜鸟接单子的时候也好心里有数!希望要的朋友顶一下
- 怎样获取复选框中的值,在同一页面中,急!急!
- json_encode输出后,为什么会输出undefined
这句出现问题.
主要原因可能是因为你的sql语句有语法错误
mysql_query函数后面,加上
echo mysql_error();查看一下错误提示信息.
where entries.cat_id=categories.id
ORDER BY dateposted DESC
LIMIT 1;"; 可能错误:
1 dateposted在两个表里都有这个字段,如果有,请在前面加上你需要按照操作的表名.
2 字段或者表名写错了.呵呵.
mysql_select_db(数据库名)
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Not connected : ' . mysql_error());
}// make foo the current db
$db_selected = mysql_select_db('foo', $link);
if (!$db_selected) {
die ('Can\'t use foo : ' . mysql_error());
}