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>
Duplicate Removal
Moderator: General Moderators
Duplicate Removal
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:
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
try something like this:
Code: Select all
<?
$screenname = str_replace(" ", "", $_GETї'name']);
$screenname = str_replace("+", "", $screenname);
$screenname = str_replace("%20", "", $screenname);
$screenname = htmlentities($screenname);
$dbconn = mysql_connect("localhost", "username", "pass");
mysql_select_db("screenames", $dbconn) or die('Db selection failed');
$qry = mysql_query("SELECT * FROM sns WHERE sn = '$screenname'");
if(@mysql_num_rows($qry) == "0"){
mysql_query("INSERT INTO sns (sn) VALUES ('$screenname')");
}
$sql = "SELECT sn FROM sns";
$result = mysql_query( $sql );
while ($data = mysql_fetch_assoc($result))
{
echo "<a href="aim:goim?sreeenname=".
$dataї'sn']."&message=Hello+Are+you+there?">".
$dataї'sn']."</a><br>\n";
}
?>
and mah link to this page for aim looks like this:
<a href="http://page/aimthingy.php?name=%n" target="_self> page </a>that worked on my computer... the one i was testing on... however when i moved it to my webserver it seemd as though it wasnt writing... see... the one that is in there i put to make sure it was retreieveing it.....
http://www.craka.com/profile/aim.php?na ... screenname
any suggestions?
http://www.craka.com/profile/aim.php?na ... screenname
any suggestions?