I tried to do it but it is not doing anything.. I commented out
//$importdata = mysql_query($query_importdata, $importer) or die(mysql_error());
and added
$importdata = mysql_query($query_importdata, $importer);
if (mysql_errno($importdata)!= 0){
//write out the bad data to a file
echo ("there is an error in the database...");
}
now it skips the insert query alltogether... can you look at my code and tell me what I did wrong?
Thanks....
<start code>
<?php require_once('importer.php'); ?>
<?
$filename = $_POST['filename'];
$row = 1;
$fp = fopen ("$filename","r");
while ($data = fgetcsv ($fp, 1000, ",")) {
$num = count ($data);
$first = $data[0];
$last= $data[1];
$valid = $data[7];
mysql_select_db($database_importer, $importer);
$query_importdata = "INSERT into users_copy (fName, lName, validation) values ('$first', '$last', '$valid')";
//$importdata = mysql_query($query_importdata, $importer) or die(mysql_error());
$importdata = mysql_query($query_importdata, $importer);
if (mysql_errno($importdata)!= 0){
//write out the bad data to a file
echo ("there is an error in the database...");
}
//end loop
/*
*/
$row++;
for ($c=0; $c < $num; $c++) {
// print $data[$c] . "<br>\n";
}
}
fclose ($fp);
print "Records from $filename were successfully inserted!<br><br>";
$return = @unlink($filename);
if ($return == true){
echo "<br>$filename was deleted from the server";
}
?>
</end code>