Hey Nate,
_____________________________________________
<[EMAIL PROTECTED]> wrote in message
001001c136af$7c649db0$[EMAIL PROTECTED]">news:001001c136af$7c649db0$[EMAIL PROTECTED]...
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!"
_____________________________________________________
<?
//Check for the IP
$result2 = mysql_query("SELECT ip FROM ip where ip = '$REMOTE_ADDR'",$db);
// You need to check whether or not an entry exists in the database
if (mysql_num_rows($result2) == 0) {
echo "No results found.";
} else {
// match found here
while($myrow = mysql_fetch_array($result2))
{
echo "Print some text here!";
}
}
?>
Don't you want to iterate more details from the result set about the client?
Otherwise, fetching the array is pointless - you're selecting from the table
and you're fetching a result that you already know the details of, because
you're asking for a match on the value. You need to amend the query if you
want more details.
I would do something like this: Say you have the details of when they were
last logged on in a value in your db called "last_login":
<?
$check = @mysql_query("SELECT last_login FROM table WHERE ip
='$REMOTE_ADDR'", $db)
or die ("Some error.");
if (mysql_num_rows($check) == 0) {
echo "The user wasn't found.";
} else {
echo "The user has been here before. See the logins below.<br><br>";
while($row = mysql_fetch_array($check)) {
$last_login = $row['last_login'];
echo $last_login . "<br>"; // Do some better formatting than this
}
}
?>
I'd do more than just use $REMOTE_ADDR too, but you get the picture.
HTH,
James
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]