PostgreSQl and PHP array

Crystal Li crystal.li at IDISIS.COM
Fri Dec 28 15:56:38 EST 2007


Hello All,

I have a question for array, I am using:
- Apache version 2.0.58
- PHP version 4.4.3-dev
- MapServer 4.8.3 CGI and MapScript (CSharp, Java, PHP,
  Python)
In PostgreSQL database, I create a array called purchase_factor varchar[],
this arrary should get data from checkbox.
I tried the different scripts:

1)
 $purchase_factor = array
 ("clim" => "!isset($_POST['ChkHomeFactor_clim']? NULL:
pg_escape_string($_POST
['ChkHomeFactor_clim']))","dist" => "!isset($_POST['ChkHomeFactor_dist']?
NULL: pg_escape_string($_POST
['ChkHomeFactor_dist']))");

and

 foreach ($purchase_factor as $key => $value) {
        $result = pg_execute($db, purchase_factor($key, $value));
      if (!$result) {
         die("Error in SQL query (country '$key'): " . pg_last_error());
          }
        }
2)

$purchase_factor = array();
 array_push($purchase_factor,
      "!isset($_POST['ChkHomeFactor_clim']? NULL:
pg_escape_string($_POST['ChkHomeFactor_clim']))",
      "!isset($_POST['ChkHomeFactor_dist']? NULL:
pg_escape_string($_POST['ChkHomeFactor_dist']))",
      "!isset($_POST['ChkHomeFactor_atmo']? NULL:
pg_escape_string($_POST['ChkHomeFactor_atmo']))",
      "!isset($_POST['ChkHomeFactor_recr']? NULL:
pg_escape_string($_POST['ChkHomeFactor_recr']))",
         "!isset($_POST['ChkHomeFactor_fami']? NULL:
pg_escape_string($_POST['ChkHomeFactor_fami']))",
             "!isset($_POST['ChkHomeFactor_priv']? NULL:
pg_escape_string($_POST['ChkHomeFactor_priv']))",
             "!isset($_POST['ChkHomeFactor_envi']? NULL:
pg_escape_string($_POST['ChkHomeFactor_envi']))",
             "!isset($_POST['ChkHomeFactor_cost']? NULL:
pg_escape_string($_POST['ChkHomeFactor_cost']))",
             "!isset($_POST['ChkHomeFactor_area']? NULL:
pg_escape_string($_POST['ChkHomeFactor_area']))",
             "!isset($_POST['ChkHomeFactor_inve']? NULL:
pg_escape_string($_POST['ChkHomeFactor_inve']))",
             "!isset($_POST['ChkHomeFactor_othe']? NULL:
pg_escape_string($_POST['ChkHomeFactor_othe']))");

both methods were not working....no error, but the data did not be writen
into table..............

and I found online help:


*Note: *A limitation of the present array implementation is that individual
elements of an array cannot be SQL NULLs. The entire array can be set to
NULL, but you can't have an array with some elements NULL and some not.
Fixing this is on the to-do list.
Since this array get data from a checkbox, it's element might be null. If
anyone is familiar with this question and give me some suggest, I really
appreciate your time and help.

All the best wishes for you all in the new year!

Crystal
-- 
=========================
Crystal Li
Systems Analyst
Idisis, Inc.
430, 318 11th Avenue S.E.
Calgary, Alberta T2G 0Y2
www.idisis.com
E-mail: crystal.li at idisis.com
Office: (403)670-7351
Fax: (403) 670-7359
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20071228/0970bffe/attachment.html


More information about the mapserver-users mailing list