chriscloyd Posted August 15, 2006 Share Posted August 15, 2006 i get this error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/.giro/thegtz/aspire-hosting.net/includes/latestthreads.php on line 5and my code is [code]<?phpinclude("threaddb.php");$latest = mysql_query("SELECT * FROM 'thread' ORDER BY date DESC 'threadid' LIMIT '7'");echo '<table width="193" border="0" bordercolor="#000000" bgcolor="#FFFFFF">';while ($row = mysql_fetch_array ($latest)){echo '<tr> <td width="105"><div align="left">'.$row['title'].'</div></td> <td width="78"><div align="center"><a href="forums/showthread.php?t'.$row['threadid'].'">View</a></div></td> </tr>';}echo '</table>';?>[/code]can someone help me fast please Quote Link to comment Share on other sites More sharing options...
hostfreak Posted August 15, 2006 Share Posted August 15, 2006 Try:[code]<?phpinclude("threaddb.php");$latest = mysql_query("SELECT * FROM 'thread' ORDER BY date DESC 'threadid' LIMIT '7'");while ($row = mysql_fetch_array ($latest)){$title = $row['title'];$threadid = $row['threadid'];?><table width="193" border="0" bordercolor="#000000" bgcolor="#FFFFFF">'; <tr> <td width="105"><div align="left"><?php echo $title; ?></div></td> <td width="78"><div align="center"><a href="forums/showthread.php?t=<?php echo $threadid; ?>'">View</a></div></td> </tr><?php}echo '</table>';?>[/code] Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted August 15, 2006 Author Share Posted August 15, 2006 Nope same error Quote Link to comment Share on other sites More sharing options...
hostfreak Posted August 15, 2006 Share Posted August 15, 2006 Not sure if it matters, but try:[code]<?phpinclude("threaddb.php");$latest = mysql_query("SELECT * FROM 'thread' ORDER BY date DESC 'threadid' LIMIT '7'");while ($row = mysql_fetch_array($latest)){ //took out the space$title = $row['title'];$threadid = $row['threadid'];?><table width="193" border="0" bordercolor="#000000" bgcolor="#FFFFFF">'; <tr> <td width="105"><div align="left"><?php echo $title; ?></div></td> <td width="78"><div align="center"><a href="forums/showthread.php?t=<?php echo $threadid; ?>'">View</a></div></td> </tr><?php}echo '</table>';?>[/code] Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted August 15, 2006 Author Share Posted August 15, 2006 thats what i did Quote Link to comment Share on other sites More sharing options...
hostfreak Posted August 15, 2006 Share Posted August 15, 2006 It's different than the first one I posted, I commented on the slight difference. I said I wasn't sure if it mattered, but the first one was:[code]while ($row = mysql_fetch_array ($latest)){[/code]The second one was:[code]while ($row = mysql_fetch_array($latest)){ //took out the space[/code] Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted August 15, 2006 Author Share Posted August 15, 2006 ya i did and it still doesnt lolany other way of doing what im trying to do im trying to get the 7 newest rows by id from threads Quote Link to comment Share on other sites More sharing options...
hostfreak Posted August 15, 2006 Share Posted August 15, 2006 Are you sure "thread" is a table in the database? And that date, threadid, and title are all fields in the table "thread" ? Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted August 15, 2006 Author Share Posted August 15, 2006 ya the error im getting now is You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'threadid LIMIT 7' at line 1and my mysql_query is mysql_query("SELECT * FROM thread ORDER BY threadid DESC threadid LIMIT 7") or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
hostfreak Posted August 15, 2006 Share Posted August 15, 2006 I think the problem might be:[code]$latest = mysql_query("SELECT * FROM 'thread' ORDER BY date DESC 'threadid' LIMIT '7'");[/code]Try changing that to:[code]$latest = mysql_query("SELECT * FROM 'thread' ORDER BY date, threadid DESC LIMIT 0, 7");[/code] Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted August 15, 2006 Author Share Posted August 15, 2006 i fixed it i took out threadid after desc but now it messes up my whole page :( Quote Link to comment Share on other sites More sharing options...
hostfreak Posted August 15, 2006 Share Posted August 15, 2006 Why was the threadid in there anyways? Were you trying to order the page by the threadid as well? Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted August 15, 2006 Author Share Posted August 15, 2006 ya but i already had it b4 desc thats why. but now its messing up my whole page [url=http://www.aspire-hosting.net]www.aspire-hosting.net[/url] Quote Link to comment Share on other sites More sharing options...
hostfreak Posted August 15, 2006 Share Posted August 15, 2006 Yeah, the page really is messed up. Can you maybe post your whole code? Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted August 15, 2006 Author Share Posted August 15, 2006 i fixed it but now its only showing a one! Quote Link to comment Share on other sites More sharing options...
hostfreak Posted August 15, 2006 Share Posted August 15, 2006 Most likely you moved the "}" to where after the rows were selected? It won't work then because it cannot loop through all the results. Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted August 15, 2006 Author Share Posted August 15, 2006 now its not showing anything Quote Link to comment Share on other sites More sharing options...
hostfreak Posted August 15, 2006 Share Posted August 15, 2006 Can you post the code your using that's not showing anything? Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted August 15, 2006 Author Share Posted August 15, 2006 [code]<?phpinclude("threaddb.php");$latest = mysql_query("SELECT * FROM thread ORDER BY threadid DESC LIMIT 7") or die(mysql_error());echo '<table width="193" border="0" bordercolor="#000000" bgcolor="#FFFFFF">';while ($row = mysql_fetch_array($latest)){$title = $row['title'];$threadid = $row['threadid'];echo '<tr> <td width="105"><div align="left">'.$title.'</div></td> <td width="78"><div align="center"><a href="forums/showthread.php?t'.$threadid.'">View</a></div></td> </tr>';}echo '</table>';?>[/code] Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted August 15, 2006 Author Share Posted August 15, 2006 look on the normal page http://www.aspire-hosting.net/includes/latestthreads.phpit shows it but when u go tohttp://www.aspire-hosting.netit wont Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted August 15, 2006 Author Share Posted August 15, 2006 so?any ideas? Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted August 15, 2006 Author Share Posted August 15, 2006 i just dont know why it will work when u go to the actuall page like http://www.aspire-hosting.net/includes/latestthreads.phpbut not when u go tohttp://www.aspire-hosting.netI have tried where i just post the code on the index.php file but it still wont show! Quote Link to comment 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.