velocite Posted February 26, 2008 Share Posted February 26, 2008 Hi everyone, I am kinda new to this PHP coding thing, I was wondering if you guys could help me with this: <?php include('connect.php'); include('config.php'); $query = mysql_query("SELECT * FROM news ORDER BY news_id DESC"); $totalnews = @mysql_num_rows($query); $i = "0"; if ($totalnews == '0') { echo "<div class='nonews'>"; echo "News has not been added."; echo "</div>"; } else { while($row = mysql_fetch_array($query)) { $news[$i]['news_id'] = $row[$i]['news_id']; $news[$i]['news_title'] = $row[$i]['news_title']; $news[$i]['news_body'] = $row[$i]['news_body']; echo " <div class='newshead'> ".$news[$i]['news_title']." </div> <div class='newsbody'> ".$news[$i]['news_body']." </div> </br> "; $i++; } } ?> what i am trying to do is basically connect to the database, then try using classes to get and display the news by its news_id. I have no idea what I am doing wrong, as it isn't displaying the news. Please help, thanks everyone Link to comment https://forums.phpfreaks.com/topic/93072-displaying-news/ Share on other sites More sharing options...
DarkerAngel Posted February 26, 2008 Share Posted February 26, 2008 in development after every mysql_query() [add] or die("MySQL Error:\nMySQL Returned: ".mysql_error()); remove the [add] for the script Link to comment https://forums.phpfreaks.com/topic/93072-displaying-news/#findComment-476838 Share on other sites More sharing options...
velocite Posted February 26, 2008 Author Share Posted February 26, 2008 in development after every mysql_query() [add] or die("MySQL Error:\nMySQL Returned: ".mysql_error()); remove the [add] for the script Ohh ok, so doing that tells me the problem, thanks DarkerAngel Valuable tip Link to comment https://forums.phpfreaks.com/topic/93072-displaying-news/#findComment-476841 Share on other sites More sharing options...
uniflare Posted February 26, 2008 Share Posted February 26, 2008 personally i keep the "or die" procedures so i can log them to a db or file, along with lots of other info so if something goes wrong an admin/moderator can debug it. though if you have a perfect script then you shouldn't need to log anything Link to comment https://forums.phpfreaks.com/topic/93072-displaying-news/#findComment-476872 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.