empty() functionality

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
anon404
Forum Newbie
Posts: 12
Joined: Wed Dec 23, 2009 4:09 am

empty() functionality

Post by anon404 »

I need to know why the empty function doesn't return true for $query (which is empty). I am using $row[0] instead because it is working as desired with empty();

Code: Select all

{
    mysql_connect("localhost", "root", "password") or die(mysql_error());
    mysql_select_db("bot") or die(mysql_error());
    echo $movie . "<br/>";
    $query = "SELECT rawTitle FROM movies WHERE rawTitle='$movie'";
    $result = mysql_query($query);
    $row = mysql_fetch_row($result);
    echo "query col 1: " . $row[0] . "<br/>";
    echo "query col 2: " . $row[1] . "<br/>";
    echo "query col 3: " . $row[2] . "<br/>";
    echo "query col 4:" . $row[3] . "<br/>";
    if(empty($row[0])) {
        return true;
    }else{
        return false;
    }
}
Last edited by Benjamin on Tue Feb 23, 2010 1:23 am, edited 1 time in total.
Reason: Changed code type from text to php.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: empty() functionality

Post by s.dot »

Code: Select all

$query = "SELECT rawTitle FROM movies WHERE rawTitle='$movie'";
How is that empty() ? :P
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
anon404
Forum Newbie
Posts: 12
Joined: Wed Dec 23, 2009 4:09 am

Re: empty() functionality

Post by anon404 »

LOL oh dear, i shouldn't be on the computer until i've been awake for at least 30 minutes 8O :oops: :P
Post Reply