Hey. Need a little help please. Basically I have a script which takes a list of IPs out of a MySQL database and if the user's IP is not in the array, then it adds it to the list and updates the database. However, it keeps adding a comma as a value in the array somewhere in the process of exploding and imploding the IPs.
Here's my code
I've cleaned it up a bit for the sake of this post. Any help will be very much appreciated.
Here's my code
PHP:
$ip = $_SERVER['REMOTE_ADDR'];
$query = mysql_query("SELECT * FROM events WHERE id='$id'");
while ($row = mysql_fetch_array($query)) {
$views = stripslashes($row['views']);
}
$views_array = array();
if ($views == "") {
$views_array[] = $ip;
}
else {
$views_array = explode($views,',');
if (!in_array($ip, $views_array)) {
$views_array[] = $ip;
}
}
$query = mysql_query("UPDATE bp_events SET views='".implode(",", $views_array)."' WHERE id = '$id'");
I've cleaned it up a bit for the sake of this post. Any help will be very much appreciated.







