I'm uploading a csv from a form. I'm trying to use mysql_affected_rows to determine if it was successful. The data is uploading into table but the mysql_affected_rows does not evaluate to true. Please help:
<?php
session_start();
$idnewtest1 = $_GET['idnewtest1'];
move_uploaded_file($_FILES["fileCSV"]["tmp_name"],
"quiz/" . $_FILES["fileCSV"]["name"]);
$objConnect = mysql_connect("localhost","root","...") or die(mysql_error()); // Conect to MySQL
$objDB = mysql_select_db("testing");
$objCSV = fopen("quiz/".$_FILES["fileCSV"]["name"], "r");
fgetcsv($objCSV, 1000, ","); // skip first row
while (($objArr = fgetcsv($objCSV, 1000, ",")) !== FALSE) {
$strSQL = "INSERT INTO ex_question1 ";
$strSQL .="(id,test_name,q_nr,....) ";
$strSQL .="VALUES ";
$strSQL .="('0','".$idnewtest1."','".$objArr[0]."'....) ";
$objQuery = mysql_query($strSQL);
}
fclose($objCSV);
if (mysql_affected_rows() > 1) {
echo "Import completed.";
}
?>