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 Link to comment https://forums.phpfreaks.com/topic/17592-mysql_fretch_array/ 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] Link to comment https://forums.phpfreaks.com/topic/17592-mysql_fretch_array/#findComment-74959 Share on other sites More sharing options...
chriscloyd Posted August 15, 2006 Author Share Posted August 15, 2006 Nope same error Link to comment https://forums.phpfreaks.com/topic/17592-mysql_fretch_array/#findComment-74960 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] Link to comment https://forums.phpfreaks.com/topic/17592-mysql_fretch_array/#findComment-74961 Share on other sites More sharing options...
chriscloyd Posted August 15, 2006 Author Share Posted August 15, 2006 thats what i did Link to comment https://forums.phpfreaks.com/topic/17592-mysql_fretch_array/#findComment-74963 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] Link to comment https://forums.phpfreaks.com/topic/17592-mysql_fretch_array/#findComment-74964 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 Link to comment https://forums.phpfreaks.com/topic/17592-mysql_fretch_array/#findComment-74965 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" ? Link to comment https://forums.phpfreaks.com/topic/17592-mysql_fretch_array/#findComment-74966 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()); Link to comment https://forums.phpfreaks.com/topic/17592-mysql_fretch_array/#findComment-74968 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] Link to comment https://forums.phpfreaks.com/topic/17592-mysql_fretch_array/#findComment-74970 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 :( Link to comment https://forums.phpfreaks.com/topic/17592-mysql_fretch_array/#findComment-74971 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? Link to comment https://forums.phpfreaks.com/topic/17592-mysql_fretch_array/#findComment-74972 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] Link to comment https://forums.phpfreaks.com/topic/17592-mysql_fretch_array/#findComment-74973 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? Link to comment https://forums.phpfreaks.com/topic/17592-mysql_fretch_array/#findComment-74976 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! Link to comment https://forums.phpfreaks.com/topic/17592-mysql_fretch_array/#findComment-74977 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. Link to comment https://forums.phpfreaks.com/topic/17592-mysql_fretch_array/#findComment-74978 Share on other sites More sharing options...
chriscloyd Posted August 15, 2006 Author Share Posted August 15, 2006 now its not showing anything Link to comment https://forums.phpfreaks.com/topic/17592-mysql_fretch_array/#findComment-74981 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? Link to comment https://forums.phpfreaks.com/topic/17592-mysql_fretch_array/#findComment-74982 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] Link to comment https://forums.phpfreaks.com/topic/17592-mysql_fretch_array/#findComment-74984 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 Link to comment https://forums.phpfreaks.com/topic/17592-mysql_fretch_array/#findComment-74985 Share on other sites More sharing options...
chriscloyd Posted August 15, 2006 Author Share Posted August 15, 2006 so?any ideas? Link to comment https://forums.phpfreaks.com/topic/17592-mysql_fretch_array/#findComment-74988 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! Link to comment https://forums.phpfreaks.com/topic/17592-mysql_fretch_array/#findComment-74990 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.