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.
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. You can check here... http://123seotalk.com/pagerank-checker
$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:
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.
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?
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). Every day's a school day, always learning!
That's not html code. It's PHP code. What you're going to have to do is make a dynamic url, such as http://www.prchecker.info?url=http://www.fakewebpage.com Then you would use the variable $_GET['url'] with your getpagerank function. It's much more complicated.