php - mysql select with 3 conditions issue -


Hello my problem, that if I change my IP but I have only one cookie which it says on the second statement.

Goes and executes the query when it should fail I do not know why it takes the $ cookie parameter in the calculation.

  & lt ;? Php require_once ('../ core / dbconfig.php'); $ Dbc = mysqli_connect (DB_SERVER, DB_USERNAME, DB_PASS, DB_NAME); $ Ip_adress = $ _ server ['REMOTE_ADDR']; $ Cookie = $ _ cookie ['cookie']; $ Id_user = $ _ post ['id_user']; $ Query = "IP_Cookie_Verify * Select * ID_User = '$ id_user' and cookie = '$ cookie' and IP = '$ ip_adress'"; $ Result = mysqli_query ($ dbc, $ query) or die ("query failed:". Mysqli_error ($ dbc)); If ($ line = mysqli_fetch_array ($ result)) {echo'fail '; } And {$ query = "IP_Cookie_Verify (IP, ID_User, Cookie) VALUES ('$ ip_adress', '$ id_user', '$ cookie')"; $ Result = mysqli_query ($ dbc, $ query) or die ("query failed:". Mysqli_error ($ dbc)); $ Queryz = "Update` user 'SET Voturi = Voturi + 1 where id =' $ id_user '"; $ Resultz = mysqli_query ($ dbc, $ queryz) or die ("query failed:". Mysqli_error ($ dbc)); Select $ Query = "Choose from` user` *, where id = '$ id_user' "; $ Result = mysqli_query ($ dbc, $ query) or die ("query failed:". Mysqli_error ($ dbc)); While ($ row = mysqli_fetch_array ($ result)) {$ voturi = $ row ['Voturi']; } "Resonance" $ Voturi ''; }   

In the query you check for the IP address but if you This query fails and returns no result, your second condition is executed.

Change your query like this:

  $ Query = "IP_Cookie_ verify * from * select * ID_User = '$ id_user' and (cookie = '$ cookie' or ip = '$ Ip_adress') ";    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -