i've been doing my php-mysql project and i came to the part in which i found out that my code doesn't have validation wherein it saves all data that a log file has and now im banging my head in my bedroom wall because i can't make it work.
here's a part of my code:
Code: Select all
if($done){
if(move_uploaded_file($_FILES['logFile']['tmp_name'], $filepath.$filename) == true)
$fileuploaded = 1;
$fileopen = fopen($filepath.$filename, "r");
$sql = "";
if($fileuploaded){
$fileopen = fopen($filepath.$filename, "r");
$sql = "INSERT INTO temployeeattendancelog
(`AccessNo`
, `AccessNoPerMall`
, `DateLog`
, `TimeLog`
, `IPAddress`
, `ID_LogFileFormat`
, `ID_AttendanceLogType`)
VALUES ";
if($fileopen){
while(!feof($fileopen)){
$qCompare = "";
$qInfo = array();
$qQuery = "select AccessNo, AccessNoPerMall, DateLog, TimeLog
from temployeeattendancelog";
$qResults = $c->query($qQuery);
$ctr = 0;
while($row = $c->get_data($qResults)){
$AccessNo[$ctr] = $row['AccessNo'];
$AccessNoPerMall[$ctr] = $row['AccessNoPerMall'];
$DateLog[$ctr] = $row['DateLog'];
$TimeLog[$ctr] = $row['TimeLog'];
$content = fgets($fileopen);
$content = explode(",", $content);
if(trim($content[0]) != "" || trim($content[0]) != 0){
if($AccessNoPerMall[$ctr] == '".trim($content[1])"'
&& $DateLog[$ctr] == str_to_date('".trim($content[2])."', '%m/%d/%Y')
&& $TimeLog[$ctr] == '".trim($content[3])."'){
}//end of if($qInfo)
else{
$sql.= "
(
'".$branchcode."-".(int)trim($content[1])."'
, ".(int)trim($content[1])."
, str_to_date('".trim($content[2])."', '%m/%d/%Y')
, '".trim($content[3])."'
, '".trim($content[0])."'
, '$idLogFile'
, case when '".trim($content[4])."' = 'I' then '1' else '2' end ),";
}//end of else ($qInfo)
}//end of if(trim)
$ctr++;
}//end ofwhile
}//end of first/outer-most while
}//end of if(fileopen)Any ideas is greatly appreciated..
(i really need your help guys..)
::im sorry if my English is poor, please bear with me..