You are here: crlf causes problems in array functions « PHP Programming Language « IT news, forums, messages
crlf causes problems in array functions

Posted by Vic Spainhower on 11/03/06 23:57

Hello,

I am exporting a table from MS Access which is then imported into a MySQL
table. I am using a TransferText command in Access to export the data to a
TAB delimeted file. Then using the following PHP routine, it is imported
into the MySQL table. One of the fields in the Access data can contain
imbedded CRLF which causes the following code to fail with the error "Column
count doesn't match value count at row 1"

If the last field in the data file doesn't contain an imbedded CRLF the code
works properly. I've tried stripping the CRLF with $line =
trim($fcontents[$i],"\r\n"); but that doesn't work.

Can someone tell me why this doesn't work?

Thanks,

Vic


$fcontents = file ('./'.$facilitiesName);
for($i=0; $i<sizeof($fcontents); $i++) {
$line = trim($fcontents[$i]);
$arr = explode("\t", $line);
$sql = "insert into $tableFacilities values ('".
implode("','", $arr) ."')";
mysql_query($sql);
//echo $sql ."<br>\n";
if(mysql_error()) {
echo mysql_error() ."<br>\n";
}
}

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация