www.webdeveloper.com
Results 1 to 4 of 4

Thread: Not handling the null field

  1. #1
    Join Date
    Sep 2010
    Posts
    68

    Not handling the null field

    I have purposefully made one of my options the null or "" option. When the null option is executed there is an if statement to handle it:

    Code:
    $id  = mysql_fetch_array($result, MYSQL_ASSOC);
    if ($id == ""){
        	return header("http://www.site.com/index.htm");
    }
    The rest of the sql part works. I just keep getting an error:

    mysql_fetch_array() expects parameter 1 to be resource, boolean ...
    Why is it not handling the null field?
    Last edited by Philosophaie; 02-29-2012 at 03:41 PM.

  2. #2
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    The database is returning null, not a value or recordset. If you can, set it so that if the return value is null then a default value is returned.
    |||||
    o . Q
    ___ "You live and you learn; or you don't live long." - Lazarus Long

    ^_^

  3. #3
    Join Date
    Sep 2010
    Posts
    68
    I can not find anything wrong with the database or the surrounding code. It is just the same as what I usually use:

    Code:
    mysql_select_db('database1');

  4. #4
    Join Date
    Mar 2009
    Posts
    452
    try $result=mysql_query("your query here") or die(mysql_error());

    to find out if your query is running properly...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles