Login   Register  
PHP Classes

Excellent, but small bug found

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      CSV Handler  >  All threads  >  Excellent, but small bug found  >  (Un) Subscribe thread alerts  
Subject:Excellent, but small bug found
Summary:Small bug found in parsing headers
Author:Lee Griffiths
Date:2013-05-14 19:52:32
Update:2013-12-17 13:39:01

  1. Excellent, but small bug found   Reply  
Picture of Lee Griffiths
Lee Griffiths
2013-05-14 19:52:32

Thanks for building this straightforward and useful CSV handler.

I found a small bug. When I have spaces in column heading names like

'Contact email'

the commit button would not save changes for those columns. My columns names were delimited, but I guess this is an issue with extracting the column names

Changing the column names to something like


fixed this


  2. Re: Excellent, but small bug found   Reply  
Picture of Heart
2013-12-17 13:22:03 - In reply to message 1 from Lee Griffiths
This is because PHP converts the following characters in $_POST to an underscore (_)

chr(32) ( ) (space)
chr(46) (.) (dot)
chr(91) ([) (open square bracket)
chr(128) - chr(159) (various)

A fast workaround for this I added

$val = str_replace(" ","_", $val);


while(list($key,$val)=each($this->HeaderData)) {

(in Update function)

  3. Re: Excellent, but small bug found   Reply  
Picture of Heart
2013-12-17 13:39:01 - In reply to message 2 from Heart
Sent too fast...

Here is the my used update function

// Administration Area
function Update($key,$data) { //Updating Item "key" with "data" named array
$headerdata_my = str_replace(" ","_", $this->HeaderData);
for($i=0;$i<count($this->ItemsList);$i++) {
while(list($key,$val)=each($headerdata_my)) {
$val_my = str_replace("_"," ", $val);
if(isset($data[$val])) $this->ItemsList[$i][$val_my]=$data[$val];