guyfromfl Posted January 10, 2011 Share Posted January 10, 2011 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 More sharing options...
guyfromfl Posted January 10, 2011 Author Share Posted January 10, 2011 Sorry.... Its Monday.. I was appending the data wrong.. I was using array_push() instead of $dup[]= array $newArray Link to comment https://forums.phpfreaks.com/topic/224004-am-i-crazy/#findComment-1157587 Share on other sites More sharing options...
Pikachu2000 Posted January 10, 2011 Share Posted January 10, 2011 What is the print_r($dup) showing? Link to comment https://forums.phpfreaks.com/topic/224004-am-i-crazy/#findComment-1157590 Share on other sites More sharing options...
guyfromfl Posted January 10, 2011 Author Share Posted January 10, 2011 it was showing "1". It was how I was handling the array data. Thanks Link to comment https://forums.phpfreaks.com/topic/224004-am-i-crazy/#findComment-1157608 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.