Announcement

Collapse
No announcement yet.

ERROR WHEN ENCOUNTERING NULL, how to solve

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • ERROR WHEN ENCOUNTERING NULL, how to solve

    I have a grid that has a total and WHERE clause that involves customer_id = {...}

    I get an error (obviously!) when customer_id is NULL.

    Where do I trap this error? I tried in onRecord, but does not work, e.g I put, as a test:

    IF ({customer_id} = ''){
    {customer_id} = 1;
    }

    Does not work. Also tried:

    if (isset({customer_id})) {
    {customer_id} = {customer_id};
    }else
    {{customer_id} = 1;}

    Does not work.

  • #2
    To test if values are equal in php you need to use == in stead of = so:

    if ({customer_id}=='') etc.
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

    Comment


    • #3
      Originally posted by aducom View Post
      To test if values are equal in php you need to use == in stead of = so:

      if ({customer_id}=='') etc.
      Thanks. But ...
      if ({customer_id} == '') {
      {customer_id} = 1;
      }

      does not work.

      Comment


      • #4
        http://www.php.net/manual/en/language.types.null.php

        Comment


        • #5
          Originally posted by michael View Post
          Thanks. But ...
          if ({customer_id} == '') {
          {customer_id} = 1;
          }

          does not work.
          Why can you test/filter out NULLS in the SQL QUERY "WHERE customer_id IS NOT NULL or something similar ??

          Comment

          Working...
          X