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