Thanks. Now I need to initialize the array as the string has a variable # of fields. <br><br><div class="gmail_quote">On Mon, Jul 23, 2012 at 1:33 PM, Earnie Boyd <span dir="ltr">&lt;<a href="mailto:earnie@users.sourceforge.net" target="_blank">earnie@users.sourceforge.net</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">You haven&#39;t shown the whole command but I&#39;m going to guess you need to<br>
drop the use of &#39; around $afields[0].  So more like array(&#39;ein&#39; -&gt;<br>
$afields[0]) instead.<br>
<br>
Earnie<br>
<div><div class="h5"><br>
On Mon, Jul 23, 2012 at 4:07 PM, Anthony &lt;<a href="mailto:tony@tony-mac.com">tony@tony-mac.com</a>&gt; wrote:<br>
&gt; I am trying to insert data into a newly created table with<br>
&gt; $result = db_insert(&#39;cc_npo_storage&#39;)<br>
&gt;         -&gt;fields(array(<br>
&gt;           &#39;ein&#39; =&gt; &#39;$afields[0]&#39;,<br>
&gt;<br>
&gt; table is defined<br>
&gt; * CREATE TABLE `cc_npo_storage` (<br>
&gt; * `ein` varchar(10) NOT NULL,<br>
&gt;<br>
&gt; The data I am inserting into field ein is   ( &#39;$afields[0]&#39;)<br>
&gt; Array[0] =&gt; 010759876<br>
&gt;<br>
&gt; (I used the php command explode to take apart a delimited input string thus<br>
&gt; the array).<br>
&gt;<br>
&gt; My problem is that I am getting the following message:<br>
&gt; PDOException: SQLSTATE[22001]: String data, right truncated: 1406 Data too<br>
&gt; long for column &#39;ein&#39; at row 1: INSERT INTO {cc_npo_storage} (ein, name,<br>
&gt; city, state, country, tforeign, flagged, nid) VALUES<br>
&gt; (:db_insert_placeholder_0, :db_insert_placeholder_1,<br>
&gt; :db_insert_placeholder_2, :db_insert_placeholder_3,<br>
&gt; :db_insert_placeholder_4, :db_insert_placeholder_5,<br>
&gt; :db_insert_placeholder_6, :db_insert_placeholder_7); Array (<br>
&gt; [:db_insert_placeholder_0] =&gt; $afields[0] [:db_insert_placeholder_1] =&gt;<br>
&gt; $afields[1] [:db_insert_placeholder_2] =&gt; $afields[2]<br>
&gt; [:db_insert_placeholder_3] =&gt; $afields[3] [:db_insert_placeholder_4] =&gt;<br>
&gt; $afields[4] [:db_insert_placeholder_5] =&gt; $afields[5]<br>
&gt; [:db_insert_placeholder_6] =&gt; $afields[6] [:db_insert_placeholder_7] =&gt;<br>
&gt; $afields[7] ) in insertdata() (line 125 of<br>
&gt; \sites\all\modules\custom\input\input.module).<br>
&gt;<br>
&gt; I have googled to no avail.<br>
&gt;<br>
&gt; Thanks for any help<br>
&gt; Tony<br>
&gt;<br>
&gt; --<br>
&gt;<br>
&gt; Anthony Stefan Maciejowski<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
</div></div>&gt; --<br>
&gt; [ Drupal support list | <a href="http://lists.drupal.org/" target="_blank">http://lists.drupal.org/</a> ]<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
--<br>
Earnie<br>
-- <a href="https://sites.google.com/site/earnieboyd" target="_blank">https://sites.google.com/site/earnieboyd</a><br>
--<br>
[ Drupal support list | <a href="http://lists.drupal.org/" target="_blank">http://lists.drupal.org/</a> ]<br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br><p><b style="font-family:&#39;Lucida Handwriting&#39;,cursive;font-size:13px;background-color:rgb(255,255,255)"><i>Anthony Stefan Maciejowski</i></b></p><p>
</p><br><p></p><br>