[support] DB problem

Anthony tony at tony-mac.com
Mon Jul 23 20:07:45 UTC 2012


I am trying to insert data into a newly created table with
$result = db_insert('cc_npo_storage')
        ->fields(array(
          'ein' => '$afields[0]',

table is defined
* CREATE TABLE `cc_npo_storage` (
* `ein` varchar(10) NOT NULL,

The data I am inserting into field ein is   ( '$afields[0]')
Array[0] => 010759876

(I used the php command explode to take apart a delimited input string thus
the array).

My problem is that I am getting the following message:
*PDOException*: SQLSTATE[22001]: String data, right truncated: 1406 Data
too long for column 'ein' at row 1: INSERT INTO {cc_npo_storage} (ein,
name, city, state, country, tforeign, flagged, nid) VALUES
(:db_insert_placeholder_0, :db_insert_placeholder_1,
:db_insert_placeholder_2, :db_insert_placeholder_3,
:db_insert_placeholder_4, :db_insert_placeholder_5,
:db_insert_placeholder_6, :db_insert_placeholder_7); Array (
[:db_insert_placeholder_0] => $afields[0] [:db_insert_placeholder_1] =>
$afields[1] [:db_insert_placeholder_2] => $afields[2]
[:db_insert_placeholder_3] => $afields[3] [:db_insert_placeholder_4] =>
$afields[4] [:db_insert_placeholder_5] => $afields[5]
[:db_insert_placeholder_6] => $afields[6] [:db_insert_placeholder_7] =>
$afields[7] ) in *insertdata()* (line *125* of *
\sites\all\modules\custom\input\input.module*).

I have googled to no avail.

Thanks for any help
Tony

-- 

*Anthony Stefan Maciejowski*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20120723/5c591f8a/attachment.html 


More information about the support mailing list