PHP code fault

Discussion in 'PHP' started by iluvm, Oct 26, 2008.

  1. #1
    Hello,

    My article directory runs on a php script and I have a problem with the "Most popular article" page.

    It should generate the 100 most requested articles but instead it generates a list of every article on database in decending popularity. As there about 250K articles, this is a huge list and takes a long time to be displayed.

    I've attached the php file for this page, can anyone see the fault?
     

    Attached Files:

    iluvm, Oct 26, 2008 IP
  2. baris22

    baris22 Active Member

    Messages:
    543
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #2
    You need to check the other files. The one which has the sql query. This page does not have any query.
     
    baris22, Oct 26, 2008 IP
  3. Kyosys

    Kyosys Peon

    Messages:
    226
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I couldn't open the file for some reason, but i'll just go ahead and believe the poster above me. Find the query and add LIMIT 100
     
    Kyosys, Oct 26, 2008 IP
  4. iluvm

    iluvm Peon

    Messages:
    165
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hello,

    May sound like a silly question but how would I know where the query is? Would the file with the query in be referenced in this file then I could post the query?
     
    iluvm, Oct 26, 2008 IP
  5. iluvm

    iluvm Peon

    Messages:
    165
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I found this code in the file

    Is this the query?
     
    iluvm, Oct 26, 2008 IP
  6. baris22

    baris22 Active Member

    Messages:
    543
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #6
    do you have a file called functions or settings or something like that?
    Can you post the codes before your head tag of Most popular article.php
     
    baris22, Oct 26, 2008 IP
  7. iluvm

    iluvm Peon

    Messages:
    165
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #7
    There is one called func.php but when I open it its encoded.

    There is one called settings?
     
    iluvm, Oct 26, 2008 IP
  8. iluvm

    iluvm Peon

    Messages:
    165
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I think i've found it there's a file called queries.php, too big to post but I found this
    Would you think is it? where would I add the limit tag?
     
    iluvm, Oct 26, 2008 IP
  9. Kyosys

    Kyosys Peon

    Messages:
    226
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #9
    at the very end

    $sql="SELECT C.category_description,C.category_name,A.article_title,A.article_author,A.article_snippet,A.article_category_id,A.article_id,A.article_views FROM article_master A,category_master C where A.article_category_id=C.category_id and C.category_status=1 and A.article_status=1 and A.article_views >0 order by A.article_views desc LIMIT 100";
     
    Kyosys, Oct 26, 2008 IP
    iluvm likes this.
  10. iluvm

    iluvm Peon

    Messages:
    165
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Thank you,

    That works perfectly after inserting LIMIT, I reduced to top 50 articles and page now opens without waiting two years.

    Thanks for everyones help
     
    iluvm, Oct 26, 2008 IP
  11. Kyosys

    Kyosys Peon

    Messages:
    226
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #11
    no problem
     
    Kyosys, Oct 27, 2008 IP