Jump to content

Am I crazy?


guyfromfl

Recommended Posts

Need another set of eyes...

 

I am getting:

Warning: Invalid argument supplied for foreach() in ... on line 83

 

$dup = array();			// Create an array to store the duplicate entries.

foreach($fileList as $filename) {
if (($handle = fopen(UPLOAD_PATH.$filename, "r")) != FALSE) {
	// Create the input array
	while(($data = fgetcsv($handle, 0, ",")) != FALSE) {
		$sql = "SELECT 
					id 
				FROM 
					leads.prospect
				WHERE
					(email='{$data[3]}' OR
					phone='" . $format->stripPhoneChars($data[2]) . "')
				LIMIT 1";

		$result = $db->query($sql);

		if (mysql_num_rows($result) == 0) {
			$sql = "INSERT IGNORE INTO leads.prospect 
						(email, phone, ip, firstName, lastName, resort)
					VALUES ('" . trim($data[3]) . "', 
							'" . $format->mysqlSafe($data[2]) . "',
							'" . $format->mysqlSafe($data[5]) . "', 
							'" . $format->mysqlSafe($data[0]) . "', 
							'" . $format->mysqlSafe($data[1]) . "',
							'" . $format->mysqlSafe($data[4]) . "')";

			$result = $db->query($sql);
			$added++;
		} else {
			$dup = array_push($dup, array($data[0], $data[1]));
		}



	}

	fclose($handle);		// Close the file

} else {
	echo "<p>Could not load file $filename</p>";
}

}
echo "$added records added.";
	// Show me the duplicate data!
	echo "<h2>This is the data that would be dumped into the duplicate CSV file:</h2>
	  	<h3>" . count($dup)." Duplicates:</h3><ol>";
	print_r($dup);
	echo $dup;
	foreach($dup as $d) { // <-------------------------------------- LINE 83
		echo "<li>$d[0] $d[1] $d[2] $d[3]</li>";
	}
	echo "</ol>";

Link to comment
https://forums.phpfreaks.com/topic/224004-am-i-crazy/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.