jedney Posted February 13, 2008 Share Posted February 13, 2008 I am tyring to do some PHP code, and I have run into an error. The code looks fine, but I am new to PHP. Any help? <? // DISPLAY NAVIGATION INFORMATION $query = "SELECT * FROM news LIMIT 5 DESC"; $result = mysql_query($query); while ($row = mysql_fetch_array($result)) { echo "". $row["url"] .""; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td class=\"copyright\">Posted on ". $row["date"] ." at ". $row["time"] ." by ". $row["author"] ."</td>"; echo "</tr>"; echo "<tr>"; echo "<td class=\"norm\">". $row["content"] ."</td>"; } ?> The error is this line: while ($row = mysql_fetch_array($result)) { Thank you!! -Jon Quote Link to comment https://forums.phpfreaks.com/topic/90915-invalid-reesource/ Share on other sites More sharing options...
mpharo Posted February 13, 2008 Share Posted February 13, 2008 try this and see if you get an error... I am tyring to do some PHP code, and I have run into an error. The code looks fine, but I am new to PHP. Any help? <? // DISPLAY NAVIGATION INFORMATION $query = "SELECT * FROM news LIMIT 5 DESC"; $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_array($result)) { echo "". $row["url"] .""; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td class=\"copyright\">Posted on ". $row["date"] ." at ". $row["time"] ." by ". $row["author"] ."</td>"; echo "</tr>"; echo "<tr>"; echo "<td class=\"norm\">". $row["content"] ."</td>"; } ?> The error is this line: while ($row = mysql_fetch_array($result)) { Thank you!! -Jon Quote Link to comment https://forums.phpfreaks.com/topic/90915-invalid-reesource/#findComment-465935 Share on other sites More sharing options...
rhodesa Posted February 13, 2008 Share Posted February 13, 2008 The problem is DESC. Are you trying to order it? Which field are you trying to order by? It should look something like this: SELECT * FROM news ORDER BY myfield DESC LIMIT 5 Quote Link to comment https://forums.phpfreaks.com/topic/90915-invalid-reesource/#findComment-465937 Share on other sites More sharing options...
DyslexicDog Posted February 13, 2008 Share Posted February 13, 2008 Do you create a connection to the database somewhere else in the code because I don't see it here? Quote Link to comment https://forums.phpfreaks.com/topic/90915-invalid-reesource/#findComment-465938 Share on other sites More sharing options...
jedney Posted February 13, 2008 Author Share Posted February 13, 2008 Thank you, that line was the problem. Yes, the connection is elsewhere in the document. Thank you, -Jon Quote Link to comment https://forums.phpfreaks.com/topic/90915-invalid-reesource/#findComment-465941 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.