Jump to content

mysql problem...i think


Renlok

Recommended Posts

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]
Link to comment
https://forums.phpfreaks.com/topic/24794-mysql-problemi-think/
Share on other sites

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
Link to comment
https://forums.phpfreaks.com/topic/24794-mysql-problemi-think/#findComment-112972
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.