chornbeck
03-04-2010, 05:57 PM
My code is breaking (unexpected end) - when I remove the SQL query line that begins $result=, the error stops... What is wrong here that's causing the code to stop? I don't see any special characters in that line that would screw it up, but maybe I'm missing something?
<?
function directoryToArray($directory, $recursive) {
$array_items = array();
if ($handle = opendir($directory)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if (is_dir($directory. "/" . $file)) {
if($recursive) {
$array_items = array_merge($array_items, directoryToArray($directory. "/" . $file, $recursive));
}
$file = $directory . "/" . $file;
$array_items[] = preg_replace("/\/\//si", "/", $file);
} else {
$file = $directory . "/" . $file;
$array_items[] = preg_replace("/\/\//si", "/", $file);
}
}
}
closedir($handle);
}
return $array_items;
}
$files = directoryToArray("./inttest", false);
foreach ($files as $file) {
$handle = fopen($file, "r");
$data = fgetcsv($handle, 5000, ",");
while (($data = fgetcsv($handle, 5000, ",")) !== FALSE) {
if ($data[1] != NULL){
$scrubnumber = preg_replace("/[^0-9]/","", $data[1]);
$fname = $data[0];
$phone1 = $scrubnumber;
$arrival = $data[3];
$result=MYSQL_QUERY("INSERT INTO myrtle (LeadNumber, fname, lname, email, phone1, arrival, comments, LXSubAffld, Date, Time, location, source, ip, ProjectID)
VALUES ('NULL','$fname','$lname','$email','$phone1','$arrival','$comments','$LXSubAffld','$Date','$Time','$ location','$source','$ip','$ProjectID')") or
die('Error making query'.mysql_error());"
}
else {}
}
unlink($file);
}
?>
<?
function directoryToArray($directory, $recursive) {
$array_items = array();
if ($handle = opendir($directory)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if (is_dir($directory. "/" . $file)) {
if($recursive) {
$array_items = array_merge($array_items, directoryToArray($directory. "/" . $file, $recursive));
}
$file = $directory . "/" . $file;
$array_items[] = preg_replace("/\/\//si", "/", $file);
} else {
$file = $directory . "/" . $file;
$array_items[] = preg_replace("/\/\//si", "/", $file);
}
}
}
closedir($handle);
}
return $array_items;
}
$files = directoryToArray("./inttest", false);
foreach ($files as $file) {
$handle = fopen($file, "r");
$data = fgetcsv($handle, 5000, ",");
while (($data = fgetcsv($handle, 5000, ",")) !== FALSE) {
if ($data[1] != NULL){
$scrubnumber = preg_replace("/[^0-9]/","", $data[1]);
$fname = $data[0];
$phone1 = $scrubnumber;
$arrival = $data[3];
$result=MYSQL_QUERY("INSERT INTO myrtle (LeadNumber, fname, lname, email, phone1, arrival, comments, LXSubAffld, Date, Time, location, source, ip, ProjectID)
VALUES ('NULL','$fname','$lname','$email','$phone1','$arrival','$comments','$LXSubAffld','$Date','$Time','$ location','$source','$ip','$ProjectID')") or
die('Error making query'.mysql_error());"
}
else {}
}
unlink($file);
}
?>