Mam problem ze skryptem wybierania i wyświetlania newsów z bazy danych.
Wygląda on tak:
Kod
$news_result = mysql_query("SELECT * FROM gbsite_news ORDER BY news_id DESC");
$news_data = mysql_fetch_array($news_result);
if (mysql_num_rows($news_result) != 0)
{
while ($news_data = mysql_fetch_array($news_result))
{
$user = $news_data['news_author'];
$user_result = mysql_query("SELECT `user_id` FROM gbsite_users WHERE user_name = '$user'");
$user_data = mysql_fetch_array($user_result);
echo "
<img src='theme/img/layout/news_cat.gif' align='left' border='0' width='128' height='118'>
<font size='4'>".$news_data['news_title']."</font>
<img src='theme/img/layout/news_line.gif' border='0'>
".$news_data['news_text']."
<p align='right'><font color='#808080' size='2'> Dodano: ".$news_data['news_time'].", ".$news_data['news_date']."
Napisał: <a href='showprofile.php?id=".$user_data['user_id']."'>".$news_data['news_author']."</a> </font>
<center>
<img src='theme/img/layout/small_sep.gif' border='0'></center>";
}
}
$news_data = mysql_fetch_array($news_result);
if (mysql_num_rows($news_result) != 0)
{
while ($news_data = mysql_fetch_array($news_result))
{
$user = $news_data['news_author'];
$user_result = mysql_query("SELECT `user_id` FROM gbsite_users WHERE user_name = '$user'");
$user_data = mysql_fetch_array($user_result);
echo "
<img src='theme/img/layout/news_cat.gif' align='left' border='0' width='128' height='118'>
<font size='4'>".$news_data['news_title']."</font>
<img src='theme/img/layout/news_line.gif' border='0'>
".$news_data['news_text']."
<p align='right'><font color='#808080' size='2'> Dodano: ".$news_data['news_time'].", ".$news_data['news_date']."
Napisał: <a href='showprofile.php?id=".$user_data['user_id']."'>".$news_data['news_author']."</a> </font>
<center>
<img src='theme/img/layout/small_sep.gif' border='0'></center>";
}
}
I w przeglądarce generuje taki błąd:
Kod
<b>Warning</b>: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in <b>D:\Programy\WebServ\httpd\news.php</b> on line <b>13</b>
Linia 13 to:
Kod
$news_data = mysql_fetch_array($news_result);
Wiecie może co jest nie tak?