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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.