Forums / All Other Contributions/Addons / Does Easy Populate 1-2-5-5-csv require PHP5?

Does Easy Populate 1-2-5-5-csv require PHP5?

Locked

Views: 648

Results 1 to 2 of 2
This thread is locked. New replies are disabled.
10 Jun 2009, 1:47 PM
#1
lightningstrikes avatar

lightningstrikes

New Zenner

Join Date:
Jun 2009
Posts:
6
Plugin Contributions:
0

Does Easy Populate 1-2-5-5-csv require PHP5?

Hi,

The dowload page for Easy Populate v1-2-5-5-csv-2 says that "It now works on PHP4. (before it was just php5)".

Is this correct? I've just found a problem running EP on PHP4 that went away when I upgraded to PHP5.

I installed EP v1-2-5-5-csv-2 with Zen Cart 1.3.8a, on a fresh install with the demo database, on a Mac OS-X 10.4, PHP4, Apache 1.3.41

I downloaded the Complete CSV, made a small change to the first product description and uploaded the file.

The process ran silently - it gave no errors nor result info (i.e. a summary of the records that were uploaded) on the screen, and the change was not uploaded. Also, there were no errors in the admin/errorlogphp file.

I upgraded to PHP 5.2, and the upload now runs fine!

Has anyone else noticed similar behaviour?

Thanks

Damian H.

12 Jun 2009, 9:27 PM
#2
scrat avatar

scrat

Zen Follower

Join Date:
Dec 2005
Posts:
451
Plugin Contributions:
0

Re: Does Easy Populate 1-2-5-5-csv require PHP5?

This may help you?

phazei:

Unfortunately, I do have some ideas, but nothing that will help. Something I should have stated in my first post to this thread. I mentioned it in the other forum...

1.2.5.5.CSV will ONLY work with PHP > v5.1

fgetcsv existed in PHPv4, but fputcsv was only added in v5.1

There are custom fputcsv functions that could be put at the begining of the file that would make it work with PHP4.

I just did a quick google search and found this:

if (!function_exists('fputcsv')) {
function fputcsv(&$handle, $fields = array(), $delimiter = ',', $enclosure = '"') {
$str = '';
$escape_char = '\';
foreach ($fields as $value) {
settype($value, 'string');
if (strpos($value, $delimiter) !== false ||
strpos($value, $enclosure) !== false ||
strpos($value, "\n") !== false ||
strpos($value, "\r") !== false ||
strpos($value, " ") !== false ||
strpos($value, ' ') !== false) {

			$str2 = $enclosure;
			$escaped = 0;
			$len = strlen($value);
			for ($i=0;$i<$len;$i++) {
				if ($value[$i] == $escape_char) {
					$escaped = 1;
				} else if (!$escaped && $value[$i] == $enclosure) {
					$str2 .= $enclosure;
				} else {
					$escaped = 0;
				}
				$str2 .= $value[$i];
			}
			$str2 .= $enclosure;
			$str .= $str2.$delimiter;
		} else {
			$str .= $value.$delimiter;
		}
	}
	$str = substr($str,0,-1);
	$str .= "\n";
	return fwrite($handle, $str);
}

}

> 
> I don't know if it works, but I hope it does :D:D
> 
> 
> 
> Since most of the code for the attributes options is there it probably wouldn't be that hard to make it work.
> 
> I thought there was a column added to the db to get quantity discounts to work in that other version.  I didn't want to add anything that would require someone to have to modify the db in any way.  I wanted it to be as plug and play as possible.