php - mysql_num_rows if count is greater than 1 -


i'm using mysql_num_rows fetch data (their email & ip), if it's been input said user decline, if hasn't succeeds.

however, if change ip still successes, when shouldn't because im using same email still? it's not checking both email , ip. thankyew in advance '-'

$query = "select * tbl_1 email='$email' , ip='$ip'"; $result = mysql_query($query) or die ('unable run: ' .mysql_error()); $count = mysql_num_rows($result);  if($count==1)  { echo 'you have entered competition!'; } else { echo 'success'; } 

your code contains where email='$email' , ip='$ip'"; yet in comment wrote:

"$email=$_post['email']; submission form, , ip comes code: $ip = $_server["remote_addr"]; @ top of scripts page"

you're using $ip = $_server["remote_addr"]; should either using

$ip = $_server["remote_addr"];

or where email='$email' , ip='$ip'";

$ip , $ip not same thing, they're "two different animals altogether" ---
variables case-sensitive.

sidenote: can use or instead of and way, if tries sign different email same ip (and vice-versa), won't able to.


footnotes:

mysql_* functions deprecation notice:

http://www.php.net/manual/en/intro.mysql.php

this extension deprecated of php 5.5.0, , not recommended writing new code removed in future. instead, either mysqli or pdo_mysql extension should used. see mysql api overview further while choosing mysql api.

these functions allow access mysql database servers. more information mysql can found @ » http://www.mysql.com/.

documentation mysql can found @ » http://dev.mysql.com/doc/.


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -