<div>Hello All,</div>
<div>&nbsp;</div>
<div>I have a question for array, I am using:</div>
<div>- Apache version 2.0.58</div>
<div>- PHP version 4.4.3-dev</div>
<div>- MapServer 4.8.3 CGI and MapScript (CSharp, Java, PHP, <br>&nbsp; Python)</div>
<div>In PostgreSQL database, I create a array called purchase_factor varchar[], this arrary should get data from checkbox.</div>
<div>I&nbsp;tried&nbsp;the different scripts:</div>
<div>&nbsp;</div>
<div>1)</div>
<div>&nbsp;$purchase_factor = array<br>&nbsp;(&quot;clim&quot; =&gt; &quot;!isset($_POST[&#39;ChkHomeFactor_clim&#39;]? NULL: pg_escape_string($_POST</div>
<div>[&#39;ChkHomeFactor_clim&#39;]))&quot;,&quot;dist&quot; =&gt; &quot;!isset($_POST[&#39;ChkHomeFactor_dist&#39;]? NULL: pg_escape_string($_POST</div>
<div>[&#39;ChkHomeFactor_dist&#39;]))&quot;);</div>
<div>&nbsp;</div>
<div>and </div>
<div>&nbsp;</div>
<div>&nbsp;foreach ($purchase_factor as $key =&gt; $value) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $result = pg_execute($db, purchase_factor($key, $value));<br>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;if (!$result) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;die(&quot;Error in SQL query (country &#39;$key&#39;): &quot; . pg_last_error());
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp; </div>
<div>2)</div>
<div>&nbsp;</div>
<div>$purchase_factor = array();<br>&nbsp;array_push($purchase_factor, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;!isset($_POST[&#39;ChkHomeFactor_clim&#39;]? NULL: pg_escape_string($_POST[&#39;ChkHomeFactor_clim&#39;]))&quot;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;!isset($_POST[&#39;ChkHomeFactor_dist&#39;]? NULL: pg_escape_string($_POST[&#39;ChkHomeFactor_dist&#39;]))&quot;,
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;!isset($_POST[&#39;ChkHomeFactor_atmo&#39;]? NULL: pg_escape_string($_POST[&#39;ChkHomeFactor_atmo&#39;]))&quot;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;!isset($_POST[&#39;ChkHomeFactor_recr&#39;]? NULL: pg_escape_string($_POST[&#39;ChkHomeFactor_recr&#39;]))&quot;,&nbsp; 
</div>
<div>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;!isset($_POST[&#39;ChkHomeFactor_fami&#39;]? NULL: pg_escape_string($_POST[&#39;ChkHomeFactor_fami&#39;]))&quot;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;!isset($_POST[&#39;ChkHomeFactor_priv&#39;]? NULL: pg_escape_string($_POST[&#39;ChkHomeFactor_priv&#39;]))&quot;,
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;!isset($_POST[&#39;ChkHomeFactor_envi&#39;]? NULL: pg_escape_string($_POST[&#39;ChkHomeFactor_envi&#39;]))&quot;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;!isset($_POST[&#39;ChkHomeFactor_cost&#39;]? NULL: pg_escape_string($_POST[&#39;ChkHomeFactor_cost&#39;]))&quot;,
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;!isset($_POST[&#39;ChkHomeFactor_area&#39;]? NULL: pg_escape_string($_POST[&#39;ChkHomeFactor_area&#39;]))&quot;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;!isset($_POST[&#39;ChkHomeFactor_inve&#39;]? NULL: pg_escape_string($_POST[&#39;ChkHomeFactor_inve&#39;]))&quot;,&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;!isset($_POST[&#39;ChkHomeFactor_othe&#39;]? NULL: pg_escape_string($_POST[&#39;ChkHomeFactor_othe&#39;]))&quot;);</div>
<div>&nbsp;</div>
<div>both methods were not working....no error, but the data did not be writen into table..............</div>
<div>&nbsp;</div>
<div>and I found online help:</div>
<div>&nbsp;</div>
<p><b>Note: </b>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&#39;t have an array with some elements NULL and some not. Fixing this is on the to-do list. 
</p>
<div>Since this array get data from a checkbox, it&#39;s element might be null. If anyone is familiar with this question and give me some suggest, I really appreciate your time and help.</div>
<div>&nbsp;</div>
<div>All the best wishes for you all in the new year!</div>
<div>&nbsp;</div>
<div>Crystal<br>-- <br>=========================<br>Crystal Li<br>Systems Analyst<br>Idisis, Inc.<br>430, 318 11th Avenue S.E.<br>Calgary, Alberta T2G 0Y2<br><a href="http://www.idisis.com">www.idisis.com</a><br>E-mail: 
<a href="mailto:crystal.li@idisis.com">crystal.li@idisis.com</a><br>Office: (403)670-7351<br>Fax: (403) 670-7359 </div>