Hi all, I've got a blank on this - could be because it's late but would really appreciate any help.
Essentially I have a rating script, but there's one part I can't quite get working right. This part needs to look through a field called 'used_ips' which contains all the ip's which have voted and search through it for the current ip. If it finds the IP it should return a 1, otherwise a 0.
This is the offending code:
I was trying to use mysql_num_rows as the query is restricted to 1 row anyway (by $id for the primary key), so if it find it we'll get a 1 otherwise a 0.
That works in my head but my server throws up the following error every time - any ideas?
Essentially I have a rating script, but there's one part I can't quite get working right. This part needs to look through a field called 'used_ips' which contains all the ip's which have voted and search through it for the current ip. If it finds the IP it should return a 1, otherwise a 0.
This is the offending code:
PHP:
$voted=mysql_num_rows(mysql_query("SELECT used_ips FROM $dbname.$tbname".ratings." WHERE used_ips LIKE '%".$ip."%' AND id='".$id."' "));
I was trying to use mysql_num_rows as the query is restricted to 1 row anyway (by $id for the primary key), so if it find it we'll get a 1 otherwise a 0.
That works in my head but my server throws up the following error every time - any ideas?
Code:
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\www\xampplite\htdocs\rate.php