SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 47 of 47
  1. #26
    Non-Member salahsoft's Avatar
    Join Date
    Feb 2009
    Location
    India
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think he will get:

    Invalid News Item

    Sorry, you failed to specify a valid article.

  2. #27
    SitePoint Zealot
    Join Date
    Nov 2008
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    unfortunately the same thing i get the list of clickable titles (click them and its a dead link even though they have the correct id) and before clicking anything "Invalid News Item
    Sorry, you failed to specify a valid article." shows.

    thanks for your time and effort thus far

  3. #28
    Non-Member salahsoft's Avatar
    Join Date
    Feb 2009
    Location
    India
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think the block below will be executed:
    else
    {
    echo '<h3>Invalid News Item</h3>';
    echo '<p>Sorry, you failed to specify a valid article.</p>';
    }

  4. #29
    Non-Member salahsoft's Avatar
    Join Date
    Feb 2009
    Location
    India
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    there is no value in $_GET variable, this is why the if condition is not becoming true.

  5. #30
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Can you post the link you clicked which led you to this error? As Salahsoft stated, it appears the id is not populated, or populated incorrectly.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  6. #31
    SitePoint Zealot
    Join Date
    Nov 2008
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The invalid error shows upon loading the page, nothing is clicked. If a title is clicked then it takes u to a broken link (i have checked the id's and they are correct and populated). Not sure what you mean when you say post the link but anything else i can tell you to help let me know.

    thanks again

  7. #32
    Non-Member salahsoft's Avatar
    Join Date
    Feb 2009
    Location
    India
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    We are asking you to post the link on which titles appear. We will check it.

  8. #33
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    A broken link?

    You do have 2 separate scripts at work here don't you? One to display the links, and another to display the article?
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  9. #34
    SitePoint Zealot
    Join Date
    Nov 2008
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i do but they are within the same page as mentioned earlier?

    Salah - the page is local

  10. #35
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Ah ha,

    The first bit of code sends the user to another script to display the article, hence you're receiving a 404.

    You need to re-code the logic for this, all the elements are there, you just need to re-jig them.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  11. #36
    Non-Member salahsoft's Avatar
    Join Date
    Feb 2009
    Location
    India
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can try to resolve if you upload it to an online webhost.

  12. #37
    SitePoint Zealot
    Join Date
    Nov 2008
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm, so does that mean it would work if i put the display code into a different page (which is perfectly usable)? I just dont understand how it would know what page to send you to if this was the case..

  13. #38
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Here, place this script on the root of your server and call it newsSample.php.

    PHP Code:
    <?php
    /*
        Include connection details here!
    */
    if(isset($_GET['newsid']) && !empty($_GET['newsid']) && ctype_digit($_GET['newsid']))
    {
        
    $sSQL sprintf("SELECT title, content FROM news WHERE id = %s",
            
    $_GET['newsid']
        );
        
    $rResult mysql_query($sSQL);
        if(!
    is_resource($rResult))
        {
            echo 
    '<h3>System Error</h3>';
            echo 
    '<p>' mysql_error() . '</p>';
            echo 
    '<p><a href="/newsSample.php">Return back to archive</a>.</p>';
            exit;
        }
        if(
    mysql_num_rows($rResult) === 1)
        {
            
    $aNewsItem mysql_fetch_assoc($rResult);
            
    printf('<h3>%s</h3><p>%s</p>',
                
    htmlentities($aNewsItem['title']),
                
    htmlentities($aNewsItem['content'])
            );
            echo 
    '<p><a href="/newsSample.php">Return back to archive</a>.</p>';
        }
        else
        {
            echo 
    '<h3>Invalid News Item</h3>';
            echo 
    '<p>Sorry, no article could be found matching your request.</p>';
            echo 
    '<p><a href="/newsSample.php">Return back to archive</a>.</p>';
        }
    }
    else
    {
        
    $sSQL 'SELECT id, title FROM news';
        
    $rResult mysql_query($sSQL);
        while (
    $aNewsItem mysql_fetch_assoc($rResult))
        {
            
    printf('<a href="/newsSample.php?newsid=%s" title="%s">%s</a><br />',
                
    $aNewsItem['id'],
                
    htmlentities($aNewsItem['title']),
                
    htmlentities($aNewsItem['title'])
            );
        }
    }
    ?>
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  14. #39
    Non-Member adstiger's Avatar
    Join Date
    Nov 2008
    Location
    Canada
    Posts
    348
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You may put the display code into separate file, however, if it already contains the error i.e. $_GET variable empty, then you will again get error.

  15. #40
    SitePoint Zealot
    Join Date
    Nov 2008
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Silver just to confirm what i need to do, use the above code and save it as newsSample.php - place it in root. Then it should all work together or i need to call it (via include) in the page that contains the title links?

  16. #41
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Try it stand alone, we'll discuss the rest later.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  17. #42
    SitePoint Zealot
    Join Date
    Nov 2008
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your going to get sick of this code lol!
    right so i went to local/newsSample.php and get a blank page besides the titles of the news articles, click them and once again a dead link...

  18. #43
    Non-Member adstiger's Avatar
    Join Date
    Nov 2008
    Location
    Canada
    Posts
    348
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if possible try it stand alone on online hosting.

  19. #44
    SitePoint Zealot
    Join Date
    Nov 2008
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    tried - same problem

  20. #45
    Non-Member adstiger's Avatar
    Join Date
    Nov 2008
    Location
    Canada
    Posts
    348
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can you test each line using die() statement as mentioned by Salahsoft

  21. #46
    SitePoint Zealot
    Join Date
    Nov 2008
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can but would that not result in the same as what happened when we tried that earlier?

  22. #47
    Non-Member adstiger's Avatar
    Join Date
    Nov 2008
    Location
    Canada
    Posts
    348
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you should go line by line, this will make you find issues.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •