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>"; Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted January 10, 2011 Share Posted January 10, 2011 What is the print_r($dup) showing? Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.