Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder StealthRT's Avatar
    Join Date
    Aug 2006
    Posts
    187
    Thanks
    14
    Thanked 0 Times in 0 Posts

    Exclamation PHP Where and EOF

    Hey all i am trying to figure out what i am doing wrong with this code below:
    Code:
    $query = "SELECT * FROM emppcn WHERE LastName = '$userLastName'";
    $result = mysql_query($query);
    
    if (!$result) {die("Query failed! Query text: $query<br>Error: " . mysql_error());}
    
    if($result == ''){
    	echo "Nothing found";
    }else{
    	echo "FOUND!";
    }
    
    mysql_close($link);
    It keeps saying FOUND! when it really doesn't.... How do i check for EOF instead of the NULL? I know how to do it in ASP (rst.EOF) but i havent found something like that for PHP...

    And help would be great!

    David

  • #2
    Regular Coder PremiumBlend's Avatar
    Join Date
    Apr 2006
    Location
    Marion, Iowa
    Posts
    201
    Thanks
    0
    Thanked 13 Times in 13 Posts
    You're trying to compare the $result object to a string. Since it can't really compare to an empty string, it returns false.

    It is an object, so you'll want to call a function like this:

    Code:
    if(mysql_num_rows($result) > 0)
    My Website: DumpsterDoggy

  • Users who have thanked PremiumBlend for this post:

    StealthRT (07-23-2008)

  • #3
    Regular Coder StealthRT's Avatar
    Join Date
    Aug 2006
    Posts
    187
    Thanks
    14
    Thanked 0 Times in 0 Posts
    Yep that did it! Thanks!

    David


  •  

    Posting Permissions

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