mikelmao Posted July 22, 2008 Share Posted July 22, 2008 Hey im getting the following error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in D:\Abyss Web Server\htdocs\mikersweb\index.php on line 66 This is the index.php script <?php include 'connect.php'; $news = mysql_query("SELECT * FROM news ORDER BY id DESC"); if(mysql_num_rows($news) > 0) // line 66 <<<<<<<<<<<<<<<------------------------ { while($n = mysql_fetch_array($news)) { print "<h1>" . stripslashes($n['title']) . "</i></h1>"; print "<i><b>" . date('d-m-Y i:H', strtotime($n['date'])) . "</b></i><br>"; print nl2br(stripslashes($n['news'])) ."<br><br>"; if(isset($_SESSION['username'])) { echo "<p><a href='editnews.php?id=$n[id]'>Edit</a> || <a href='dnews.php?id=$n[id]'>Delete</a></p>"; } } } else { echo "<p>There is no news.</p>"; } if(!isset($_SESSION['username'])) { echo "<a href='login.php'>Login</a>"; } else { echo "<a href='addnews.php'>Add News</a> || <a href='cuser.php'>Create User</a> || <a href='duser.php'>Delete User</a> || <a href='logout.php'>Logout</a>"; } ?> plz help.. Thanks Link to comment https://forums.phpfreaks.com/topic/116028-mysql_num_row-error/ Share on other sites More sharing options...
mbeals Posted July 22, 2008 Share Posted July 22, 2008 Your query is breaking, thus not returning a result resource. Add echo mysql_error(); after your mysql_query(); and see what error mysql_query is throwing. Link to comment https://forums.phpfreaks.com/topic/116028-mysql_num_row-error/#findComment-596582 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.