Menu

Unknown column 'news_posts.ID' in 'on clause'

Help
adbell
2006-11-17
2013-03-14
  • adbell

    adbell - 2006-11-17

    Hi,

    PHPFreeNews has been working beautifully for several months but is now giving the following error:
    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home2/entelsof/public_html/news/Inc/ListingFunctions.php on line 67
    Query failed : Unknown column 'news_posts.ID' in 'on clause'

    My ISP has just upgraded MySQL to 5.0 from 4.1 (without any warning). So I believe the problem is being cause by the new version of MySQL (Which has been experienced by others documented at
    http://www.phpfreenews.co.uk/forums/viewtopic.php?t=343

    I believe I am running PHPFreeNEws 1.55. Is there a current step by step list of instructions to fix this problem?

    Many Thanks
    Adrian

     
    • adbell

      adbell - 2006-11-17

      Sorry I got a bit confused with the thread mentioned in my origina post (unsure if we had an official fix to the problem) but I went through and made the following changes and the problem seems to have gone away.

      1. Edit your ListingFunctions.php. Find function BuildListingSQL. Change the first line from
      Code:
      $Query = "SELECT DISTINCT news_posts.*, news_users.FullName FROM news_posts, news_users"; 
      to
      Code:
      $Query = "SELECT DISTINCT news_posts.*, news_users.FullName FROM (news_posts, news_users)"; 

      2. in NewsList.php, line 28
      Code:
      $Query = "SELECT DISTINCT news_posts.*, news_users.FullName FROM news_posts, news_users"; 
      becomes
      Code:
      $Query = "SELECT DISTINCT news_posts.*, news_users.FullName FROM (news_posts, news_users)"; 

      3. In ViewAudit.php, line 83
      Code:
      $sql = "SELECT EventDateTime, Username, CatDesc, EventType, LinkedID, news_audit.Description FROM news_audit, news_audit_categories LEFT OUTER JOIN news_users ON news_audit.EventUserID=news_users.ID WHERE news_audit.EventCatID=news_audit_categories.ID "; 
      becomes
      Code:
      $sql = "SELECT EventDateTime, Username, CatDesc, EventType, LinkedID, news_audit.Description FROM (news_audit, news_audit_categories) LEFT OUTER JOIN news_users ON news_audit.EventUserID=news_users.ID WHERE news_audit.EventCatID=news_audit_categories.ID "; 

      4. In Images.php , prior to the line
      Code:
      $ResultSet = mysql_query("SELECT * FROM news_images ORDER BY ImageName ASC LIMIT $RecStart, $AdminImagesPerPage"); 

      insert Code:
      echo "SELECT * FROM news_images ORDER BY ImageName ASC LIMIT $RecStart, $AdminImagesPerPage"; 

      e.g. the full code becomes:
      Code:
      echo "SELECT * FROM news_images ORDER BY ImageName ASC LIMIT $RecStart, $AdminImagesPerPage";
      $ResultSet = mysql_query("SELECT * FROM news_images ORDER BY ImageName ASC LIMIT $RecStart, $AdminImagesPerPage"); 

      Cheers Adrian

       

Log in to post a comment.