Welcome to Welcome to DNF.com™ - Domain Sales, Domain Forum, Domain Appraisals, Domain Registrars

If you are new to domains and looking to buy, sell and learn about domains then you have come to the right place. DNForum is the largest domain name community on the internet and continues to grow every day. There are over 105,000 domainers on DNForum doing everything from buying domains, selling domains, learning about domains and discussing domains. Take a minute and Register.

Register Today on DNForum IT'S FREE!

Results 1 to 3 of 3
  1. #1
    Platinum Lifetime Member
    sourcez's Avatar
    Join Date
    Apr 2006
    Location
    UK
    Posts
    126
    DNF$
    2,930
    Bank
    0
    Total DNF$
    2,930
    Donate  

    PHP & MySQL Problem - Checking a row for existing data

    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:

    PHP Code:
    $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

  2. #2
    Country hopper
    katherine's Avatar
    Join Date
    Jul 2005
    Location
    Free World
    Posts
    7,499
    Country

    Iceland
    DNF$
    30,536
    Bank
    0
    Total DNF$
    30,536
    Donate  
    Code:
    $result=mysql_query("SELECT used_ips FROM $dbname.$tbname".ratings." WHERE used_ips LIKE '%".$ip."%' AND id='".$id."' "));  
    $voted=mysql_num_rows($result);
    Or do a count if you just need the number of matching records, not the details
    Code:
    SELECT distinct count(used_ips) FROM $dbname.$tbname".ratings." WHERE used_ips LIKE '%".$ip."%' AND id='".$id."'
    NameNewsletter.com - free lists of available domain names
    ZoneFiles.net (beta) - ccTLD and gTLD droplists

  3. #3
    Platinum Lifetime Member
    sourcez's Avatar
    Join Date
    Apr 2006
    Location
    UK
    Posts
    126
    DNF$
    2,930
    Bank
    0
    Total DNF$
    2,930
    Donate  
    Yeah, that's nice. I did this another way but this might simplify it.

    Thanks!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Domain name forum recommended by Domaining.com