this is supposed to log the ip's of people connecting to my site but it wont work help?

<?php
$username="****";
$password="*****";
$database="ipconnect";
$ip=@$REMOTE_ADDR;
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "INSERT INTO ip VALUES ('$ip')";
mysql_query($query);
mysql_close();
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.