I have a 1400 line text file. TAB delimited.

     1974-01-13 8 Cold Storage

3 fields. nothing large or complicated.

I massaged the data to be in this format thinking it would make the import

I can open the file and drop it into an array just fine.

I can EXPLODE each array item into it's base parts (date, num, name) just

    list($strDate,$strNum,$strName) = explode ("\t", $lines[$x]);

But now I run into problems.

The 'date' will not insert into the database.
The 'num' will insert into the database.
The 'name' will not insert into the database.

well, one out of three's not so bad.  :/

This is what I'm trying to do...

    $aryFieldsValues = array( 'eps_id'       => $x,
                              'eps_name'     => $strName,
                              'eps_num'      => $strNum,
                              'eps_air_date' => $strDate);

    $strTableName = 'cbs_eps';
    $objResult = $db->autoExecute($strTableName, $aryFieldsValues,

I even did this...

  $strSql  = 'INSERT INTO `cbs_eps` ( `eps_id` , `eps_name` , `eps_num` ,
`eps_air_date` ) ';
  $strSql .= "VALUES ( ";
  $strSql .=   "'" . $x       . "', ";
  $strSql .=   "'" . $strName . "', ";
  $strSql .=   "'" . $strNum  . "', ";
  $strSql .=   "'" . $strDate . "' );";

  $objResult = $db->query($strSql);

Same results.

Can anyone tell me what I am doing wrong?

Oh, I did add this...

   // Yank off the RETURN at the end
   $strName = rtrim($strName);

   // ESCAPE all the funny stuff!
   $strName = mysql_real_escape_string($strName);

It gives me...

     \0L\0o\0s\0t\0 \0D\0o\0g     <= was 'Lost Dog'

But it still will not insert into database.


BTW: you might need to know this...

   Field         Type Attributes   Null   Default
   eps_id        tinyint(4)        No      0
   cat_id        tinyint(4)        Yes     NULL
   eps_name      varchar(100)      Yes     NULL
   eps_num       int(11)           Yes     NULL
   eps_air_date  date              Yes     0000-00-00

AND, please, someone, tell me how to make this date string '1974-01-13' into
something that mySQL will accept.

Thanks for your help.


PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to