Help with if statement please...

Discussion in 'PHP' started by Devilfish, Feb 28, 2009.

  1. Devilfish

    Devilfish Active Member

    Messages:
    396
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    70
    #21
    I did some reading on ctype_digit and in theory it should work because the value being returned from getpagerank($url) is a single number, 0-10. But it still doesn't work, it always show no pr.

    I even tried 'is_numeric' but that didn't work either. :(
     
    Devilfish, Mar 1, 2009 IP
  2. qualityfirst

    qualityfirst Peon

    Messages:
    147
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    0
    #22
    Put this before that part of the script:

    
    echo getpagerank($url);
    
    PHP:
    Tell me what comes out.
     
    qualityfirst, Mar 1, 2009 IP
  3. Devilfish

    Devilfish Active Member

    Messages:
    396
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    70
    #23
    For a PR4 domain, it returns "4" without quotes.

    This is the code I'm using;

    <fieldset>
    
    <legend><strong>Google Pagerank</strong></legend>
    
    <?php
    
    $url=$_REQUEST['url'];
    
    echo "Google Pagerank = <img src='/pr_icons/pr".getpagerank($url).".gif'><br />";
    
    echo getpagerank($url);
    $pagerank1 = getpagerank($url);
    if (ctype_digit($pagerank1)){
    echo "Google Pagerank = <img src='/pr_icons/pr".$pagerank1.".gif'><br />";
    } else {
    echo "Google Pagerank is not available!<br />";
    }
    
    ?>
    
    </fieldset>
    PHP:
    And this is what is displayed.

    untitled.JPG

    You can check here... http://123seotalk.com/pagerank-checker
     
    Devilfish, Mar 1, 2009 IP
  4. young coder

    young coder Peon

    Messages:
    302
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #24
    $pagerank = getpagerank($url);
    if ($pagerank == 1 || $pagerank == 2 || $pagerank == 3 || $pagerank == 4 || $pagerank == 5 || $pagerank == 6 || $pagerank == 7 || $pagerank == 8 || $pagerank == 9 || $pagerank == 10)
    { echo "<img scr='/pr_icons/pr".$pagerank.".gif'>";  }
    else { echo "the page rank is unknown"; }
    PHP:
     
    young coder, Mar 1, 2009 IP
    Devilfish likes this.
  5. qualityfirst

    qualityfirst Peon

    Messages:
    147
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    0
    #25
    Can you try for a N/A site and see what it outputs?
     
    qualityfirst, Mar 1, 2009 IP
  6. Devilfish

    Devilfish Active Member

    Messages:
    396
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    70
    #26
    Thank you very much, this is now working fine! :)

    I had to change the $pagerank variable to something because it's used elsewhere. ;)

    +rep added, thanks again.
     
    Devilfish, Mar 1, 2009 IP
  7. Devilfish

    Devilfish Active Member

    Messages:
    396
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    70
    #27
    I would also like to offer html code so that people can put the pr icon on their site. This is what I have and I know it's wrong but I can't figure it out...

    echo "<textarea name='icon' cols='50' rows='3'>";
    echo "<a href='http://123seotalk.com/pagerank-checker' target='_blank'><img src='http://123seotalk.com/pr_icons/pr" .getpagerank($url). ".gif' alt='Pagerank Checker' /></a>";
    echo "</textarea>";
    PHP:
    Can you help again please?
     
    Devilfish, Mar 1, 2009 IP
  8. Devilfish

    Devilfish Active Member

    Messages:
    396
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    70
    #28
    OK...getting a bit further...I've changed it to...

    <textarea name="icon" cols="50" rows="3">
    <a href='http://123seotalk.com/pagerank-checker' target='_blank'><img src='http://123seotalk.com/pr_icons/pr<?php echo $pagerank1; ?>.gif' alt='Pagerank Checker' /></a>
    </textarea>
    PHP:
    ...and it works. But it's added a line break where the php code is (see pic).

    untitled.JPG

    Every day's a school day, always learning! :)
     
    Devilfish, Mar 1, 2009 IP
  9. qualityfirst

    qualityfirst Peon

    Messages:
    147
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    0
    #29
    qualityfirst, Mar 1, 2009 IP
  10. Devilfish

    Devilfish Active Member

    Messages:
    396
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    70
    #30
    Ah I see, I'll have a read up on that, thank you. :)
     
    Devilfish, Mar 1, 2009 IP