Jump to content

Mysql_fretch_array


chriscloyd

Recommended Posts

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 5

and my code is

[code]<?php
include("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

Try:

[code]
<?php
include("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

Not sure if it matters, but try:

[code]
<?php
include("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

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

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 1

and 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

[code]<?php
include("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

i just dont know why it will work when u go to the actuall page like
http://www.aspire-hosting.net/includes/latestthreads.php
but not when u go to
http://www.aspire-hosting.net

I 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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.