Jump to content


Photo

Warning: mysql_fetch_row():


  • Please log in to reply
3 replies to this topic

#1 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 09 August 2006 - 04:26 PM

Hey.
I have this error:
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/eumod/public_html/en/index.php on line 96

and line 96:
while( $data = mysql_fetch_row($sql))
      {

code:
<?PHP
				include("db/db.php");
				$sql = mysql_query("SELECT * FROM news WHERE news_old='n' ORDER BY id DESC");
              	while( $data = mysql_fetch_row($sql))
              		{
              			$sql2 = mysql_query("SELECT * FROM comments WHERE news_id='".$data[0]."'");
              			$num = mysql_num_rows($sql2);
              					
              		echo '<div align="left">
  <table border="0" cellpadding="2" style="border-collapse: collapse" bordercolor="#111111" width="90%">
    <tr>
      <td width="100%" colspan="2"><i><b>'.$data[1].'</b></i></td>
    </tr>
    <tr>
      <td width="100%" colspan="2">'.$data[2].'</td>
    </tr>
    <tr>
      <td width="100%" colspan="2">
      <hr color="#AAD2FF" width="95%" align="left" style="border: 1px dotted #AAD2FF" size="1">
      </td>
    </tr>
    <tr>
      <td width="50%">[ '.$data[6].' | '.$data[4].' : '.$data[5].' ]</td>
      <td width="50%">
      <p align="right"><b>'.$num.'</b> <a href="#top">Comments</a> | <a href="#top">
      Read more</a>...</td>
    </tr>
  </table>
</div>
<br>';
				}
              ?>


#2 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 09 August 2006 - 04:28 PM

Try change this line:
$sql = mysql_query("SELECT * FROM news WHERE news_old='n' ORDER BY id DESC");
to
$sql = mysql_query("SELECT * FROM news WHERE news_old='n' ORDER BY id DESC") or die(mysql_error());
and tell me if it returns an error.

#3 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 09 August 2006 - 04:52 PM

Unknown column 'id' in 'order clause'

#4 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 09 August 2006 - 04:53 PM

yes I should have done that before posting really :/ Lol. and i found out the id should be news_id :/




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users