SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    derrrp
    Join Date
    Aug 2006
    Location
    earth
    Posts
    923
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with Error Checking not working properly.

    Hi,

    Can somebody please help me from going insane here? I'm echoing out my count($error_list) and it's giving me a big fat 0 (as in ZERO).

    I would assume that 0 is not greater than 0, yet that block of code runs instead of the ELSE that contains the INSERT. WHY?

    Thanks for any help.

    PHP Code:
    $status "<p>Please fill out the form and click Submit once.</p>\n";
    $showform true;

    if(
    $_POST['addbuyer'])
    {
      
    $error_list = array();
      
      
    $fname $_POST['fname'];
      
    $lname $_POST['lname'];
      
      if(empty(
    $fname))
      {
        
    $error_list[] = 'First Name is required.';
      }
      if(empty(
    $lname))
      {
        
    $error_list[] = 'Last Name is required.';
      }
      echo 
    count($error_list);
      if(
    count($error_list 0))
      {
        
    $status "<ul class=\"errormsg\">\n";
        foreach(
    $error_list as $error)
        {
          
    $status .= "<li>$error</li>\n";
        }
        
    $status .= "</ul>";
        echo 
    "Hello";
      }else
        {
          
    $sql "INSERT INTO buyers SET fname='', lname='' ;
          echo 
    $sql;
          if(mysql_query(
    $sql))
          {
            
    $status = "<p>Buyer has been addedPlease click the buton below to close this window.</p>";
            
    $showform = false;
          }
        }

    Last edited by crowden; Apr 16, 2007 at 12:51.
    No, I REALLY dislike having to use Joomla.

  2. #2
    Sell crazy someplace else markl999's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    4,007
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if(count($error_list > 0))
    should be:
    if(count($error_list) > 0)

  3. #3
    derrrp
    Join Date
    Aug 2006
    Location
    earth
    Posts
    923
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks kind sir.

    No, I REALLY dislike having to use Joomla.


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
  •