php - SOLVED: Why can't I count rows? -


solved: after fixing typo, didn't work how wanted it. fixed it. error in $ip2. since http_x_forwarded_for doesn't have input database recalled " " existing ip , didn't add new vote. fixed adding if ($ip2="") statement , adding votes.

edit: changed typo, seems give me "you voted" page proxy change ip.

edit 2: checked something: voted once , works gets added database, vote proxy gives ip1 still tells me voted already. can vote once.

so have code, returns nothing:

<?php $con = mysqli_connect("localhost","root","password","database");  $ip1 = $_server['remote_addr']; $ip2 = $_server['http_x_forwarded_for'];  if (mysqli_connect_errno())   {   echo "unable connect: " . mysqli_connect_error();   }  $count1 = mysqli_num_rows(mysqli_query($con, "select * votes voteip1 = '$ip1'")); $count2 = mysqli_num_rows(mysqli_query($con, "select * votes voteip2 = '$ip2'"));  if (($count1 > 0) || ($count2 > 0))     {     echo "you voted, can leave page.";     mysqli_close($con);     } else      {     $sql="insert votes (vote, voteip1, voteip2)     values      ('$_post[vote]','$ip1','$ip2')";      if (!mysqli_query($con,$sql))         {         die('error: ' . mysqli_error($con));         }      echo "thanks voting, can leave page.";     mysqli_close($con);     } ?> 

i have tried many different things. can please tell me doing wrong.

ps sorry english, it's not first language , still learning


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -