Renlok Posted October 23, 2006 Share Posted October 23, 2006 For a rating system i made this wassuposed to stop people voting on the same thing twice but it dusnt work. When you send a rating it enters you ip address correctly but it doesnt stop you from sending it as meny times as you want.[code] $query1 = "select * from rating where ip is $ip and url is $url"; $result1 = $db->query($query1); $num_results = $result1->num_rows; if ($num_results > 0) { echo 'You have already voted for '.$url; } else { $query = "insert into rating (ratingValue, URL, ip) values ('".$rate."', '".$url."', '".$ip."')"; $result = $db->query($query) or die ($db->error); if ($result) echo $db->affected_rows.' You have rated '.$url.'as a '.$rate; echo '<br>your ip address has been logged as '.$ip.'<br>Thankyou for using our site'; } $db->close();[/code] Quote Link to comment https://forums.phpfreaks.com/topic/24794-mysql-problemi-think/ Share on other sites More sharing options...
Jocka Posted October 23, 2006 Share Posted October 23, 2006 try changing this:$query1 = "select * from rating where ip is $ip and url is $url";to this:$query1 = "select * from rating where ip='" . $ip . "' and url='" . $url . "'"; Quote Link to comment https://forums.phpfreaks.com/topic/24794-mysql-problemi-think/#findComment-112970 Share on other sites More sharing options...
.josh Posted October 23, 2006 Share Posted October 23, 2006 yes, as mentioned, you need to use [b]=[/b] not [b]is[/b] and you need the quotes around the data. However using a concactonated string is not necessary. simply doing this:[code]$query1 = "select * from rating where ip='$ip' and url='$url'";[/code]is okay Quote Link to comment https://forums.phpfreaks.com/topic/24794-mysql-problemi-think/#findComment-112972 Share on other sites More sharing options...
Renlok Posted October 23, 2006 Author Share Posted October 23, 2006 oh ok thanks its working now Quote Link to comment https://forums.phpfreaks.com/topic/24794-mysql-problemi-think/#findComment-113052 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.