Yep It's Me Again >.> - This time with news!

Pages: 1, 2
free web hosting
Open Discussion > CONTRIBUTE > Computers > Programming Languages > PHP Programming

Yep It's Me Again >.> - This time with news!

mobious
i would like to suggest that you make sure that your sql queries are correct. that error usually shows up when the function mysql_query() return a value of false which is not a valid resource. this happens because of errors in sql queries.

Reply

HmmZ
Ive checked all the queries numberous times but I can't find the error, also, i have a file (news.php) wich has the EXACT same code of displayNews and that one is NOT showing errors....please, could it be anything else?

Reply

mobious
i really think that the problem is in the mysql_query() function. is $db your connection id to mysql? like you used it like $db = mysql_conect()? so why not do the query like this? if ever there is an error in the query, surely it will be shown completely.

CODE
function displayNews($all = 0) {
global $db, $max_items;

if ($all == 0) {
 $query = "SELECT id, title, newstext, date_format(postdate, \'%Y-%m-%d\') as date
  FROM news
  ORDER BY postdate DESC
  LIMIT $max_items";
} else {
  $query = "SELECT id, title, newstext, date_format(postdate, \'%Y-%m-%d\') as date
  FROM news
  ORDER BY postdate DESC";
 }

if (!($result = mysql_query($query, $db))) {
 exit('MySQL Query Error: ' . mysql_error() . ' | SQL Query: ' . $query . ' | Line: ' . __LINE__);
}

while ($row = mysql_fetch_assoc($result)) {
 $date = $row['date'];
 $title = htmlentities($row['title']);
 $news = nl2br(strip_tags($row['newstext'], '<a><b><i><u>'));
 
 echo "<table border=\"1\" width=\"300\" align=\"center\">\n";
 echo "<TR><TD><b>$title</b> posted on $date</td></tr>\n";
 echo "<TR><TD>$news</td></tr>\n";
 
 $comment_query = "SELECT count(*)
  FROM news_comments
  WHERE news_id={$row['id']}";
 
 if (!($comment_result = mysql_query($query, $db))) {
  exit('MySQL Query Error: ' . mysql_error() . ' | SQL Query: ' . $comment_query . ' | Line: ' . __LINE__);
 }
 
 $comment_row = mysql_fetch_row($comment_result);
 
 echo "<TR><TD><a href=\"{$_server['php_self']}"."?action=show&amp;id={$row['id']}\">Comments</a>"."($comment_row[0]}</td></tr>\n";
 echo "</table>\n";
 echo "<br>\n";
}

if ($all == 0 ) {
 echo "<a href=\"{$_server['php_self']}?action=all\">View all news</a>\n";
}
}

 

 

 


Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Pages: 1, 2
Similar Topics

Keywords : yep news

  1. Sending E-mails After News Update? - Coding needed?!? (8)
  2. Php News Script - how to make news script that uses MySQL writen in PHP (19)
    How to make a News script with PHP + MySQL So..in this tutorial i will explain how to create PHP
    news script. first we have to create the table in My SQL.. with the code below you will do this (
    you have to enter it into SQL field ..in PHPmyADMIN) CODE CREATE TABLE news ( id
    int(10) unsigned NOT NULL auto_increment, postdate timestamp(14) NOT NULL, title
    varchar(50) NOT NULL default '', content text NOT NULL, PRIMARY KEY (id),
    KEY postdate (postdate), FULLTEXT KEY content (content) ) >>...
  3. How Yahoo! Publish News ? - (3)
    I want to know how the websites like www.myway.com publish news? They do not have their own news ..
    they take from other sources... for example reuters.. most of the news from yahoo are from AP.. of
    course these websites are very big and they have some professional services..but i just want to know
    , how does this work ? What is the way to publish news on website ? Is there any news services
    which allows to print the complete news articles on others website ? Usually rss news prints only
    headlines.. if there is any information about it please let me know....
  4. News Fetching Script - (1)
    Im looking for some script which can fetch news from Reuters or any other news website and publish
    on my own webite.(of course i'll mention clearly that it is from reuters or anything else).. I
    dont mean RSS feeds where i can put only headline of some lines and then the link of the news
    website..i mean , for example on front page of my website there will be headlines..and when some one
    click on headline , it opens details of news on my own website, Not on the reutors etc.. Is it
    possible ?...
  5. Php Dynamic News Updating Using Mysql - changing a sites news using MySQL and PHP (3)
    Hey everyone. It appears to me that everyone really know what they are doing in this forum and im a
    pretty new to this PHP and MySQL combo. I know some PHP but not MySQL....I am trying to make a new
    website but i want to be able to go to a certain update page and change the news on the main index.
    For example: - The main page show news updates of the last 10 post. - I go to the update page
    and then fill in the form and it will add this post to the top of the list and still only print the
    top 10. I have no clue how to do this with MySQL. At the moment i am doing it u...



Looking for yep, time, news

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for yep, time, news

*MORE FROM TRAP17.COM*
advertisement



Yep It's Me Again >.> - This time with news!



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE