Re: mysql_fetch_array
| From: | David Robley | Date: | Thu, 06 Sep 2001 08:40:12 +0000 |
| Subject: | Re: mysql_fetch_array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-66173@lists.php.net to get a copy of this message | ||
On Thu, 6 Sep 2001 18:09, nate@1feehosting.com wrote:
> Can someone tell me what i'm doing wrong here?
>
> <?php
> //Connect to db
> $db = mysql_pconnect("localhost","login","pass");
> mysql_select_db("database",$db);
>
> //Check for the IP
> $result2 = mysql_query("SELECT ip FROM ip where ip =
> '$REMOTE_ADDR'",$db);
>
> while($myrow<>mysql_fetch_array($result2))
> {
> echo "Print some text here!";
> }
> ?>
>
> Basically I just want to print text if the IP address was not found in
> the database, and if it was found then I want to print "Print some text
> here!"
>
> Please help!
> Thanks,
> Nate
I think it would make more sense to check the number of rows found, and
act accordingly. If you don't need to use any of the info from the DB,
you could do a SELECT COUNT(ip) WHERE ....
Alternatively, test mysql_num_rows($result2).
--
David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc
CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA
He who laughs last probably made a backup.