Duplicate Removal
Posted: Tue Sep 17, 2002 10:45 pm
ok, im writing a script that will log a persons AIM screen name in MySQL when they view a subprofile page i made... it works.. but if a person views the page the script the more than once it will show their name multiple times .. I want mySQL not to log it in its database again.... What would the code look like for that.. this is the script i have written:
anyone know how i can modify it so that it doesnt log the same name mulitple times?
<?
$dbconn = mysql_connect("localhost", "username", "pass");
$result = mysql_select_db("screenames", $dbconn);
$insert = "INSERT INTO sns (sn) VALUES ('$name')";
$query = mysql_query($insert)or die(mysql_error());
mysql_close();
$dbconn = mysql_connect("localhost", "username", "pass");
$result = mysql_select_db("screenames", $dbconn);
if ( $result == false )
{
echo mysql_error();
} else {
$sql = "SELECT sn FROM sns";
$result = mysql_query( $sql );
if ( $result != false )
{
while ( $data = mysql_fetch_assoc( $result ) )
{
echo 'Name: '.
$data['name'].'<a href="aim:goim?sreeenname='.
$data['sn'].'&message=Hello+Are+you+there?">'.
$data['sn'].'</a> <br>';
}
} else {
echo mysql_error();
}
}
mysql_close();
?>
and mah link to this page for aim looks like this:
<a href="http://page/aimthingy.php?name=%n" target="_self> page </a>