Problem in importing files of xml files to mysql

Hi

I have a problem in importing .xml files in my mysql database. my .xml file is also more than 3mb, so i change in my php.ini the upload_max_filesize = from 2MB to 100MB and also i change the max_execution_time = from 30 to 1200

but still i cannot import my .xml files.

no error displayed so i cannot configured out.

here is my code for the import:


<?php

$data = array();
$con = mysql_connect("localhost", "root","");
if (!$con) { 
  die(mysql_error());
}
$db = mysql_select_db("payroll", $con);
if (!$db) { 
  die(mysql_error());
}

$sql = "select * from regular_dtr";
$result =  mysql_query($sql, $con);
if (!$result) {
    die(mysql_error());
}

function add_employee($EMP_NO, $Date, $DTR)
  {
      global $data; 
      
      $con = mysql_connect("localhost", "root","");
      if (!$con){ die(mysql_error());}
      $db = mysql_select_db("payroll", $con);
      if (!$db) { 
          die(mysql_error());
      }

      $EMP_NO = $EMP_NO;
      $Date = $Date;
      $Date = substr($Date,0,-13);
      $DTR = $DTR;
 
     $sql = "INSERT INTO regular_dtr (EMP_NO, DATE_DTR, DTR) VALUES ('$EMP_NO', '$Date', '$DTR')";
      mysql_query($sql, $con);
      
      $data []= array('EMP_NO' => $EMP_NO, 'DATE_DTR' => $Date, 'DTR' => $DTR); 
  }
  
  if ( $_FILES['file']['tmp_name'] )
  {
      $dom = DOMDocument::load( $_FILES['file']['tmp_name']);
      //ini_set('memory_limit', '150MB');   
      $rows = $dom->getElementsByTagName( 'Row' );
      global $last_row;
      $last_row = false;
      $first_row = true;
      foreach ($rows as $row)
      {
          if ( !$first_row )
          {
              $EMP_NO = "";
              $Date = "";
              $DTR = "";
              
              $index = 1;
              $cells = $row->getElementsByTagName( 'Cell' );
          
              foreach( $cells as $cell )
              { 
                  $ind = $cell->getAttribute( 'Index' );
                  if ( $ind != null ) $index = $ind;
                  
                  if ( $index == 1 ) $EMP_NO = $cell->nodeValue;
                  if ( $index == 2 ) $Date = $cell->nodeValue;
                  if ( $index == 3 ) $DTR = $cell->nodeValue;
                  $index += 1;
              }
             if ($EMP_NO=='' and $Date=='' and $DTR=='') {
                    $last_row = true;
              }      
              else {
                    add_employee($EMP_NO, $Date, $DTR);

              }      
          }
          if ($last_row==true) {
              $first_row = true;
          }     
          else {
              $first_row = false;
          }
      }
  }
?>

and


<html>
<body>
<form enctype="multipart/form-data" 
  action="import_reg_att.php" method="post">
  <input type="hidden" name="MAX_FILE_SIZE"/>
  <table width="600">
  <tr>
  <td>Employee Attendance:</td>
  <td><input type="file" name="file" /></td>
  <td><input type="submit" value="Upload" /></td>
  </tr>
  </table>
  </form>
  </body>
 </html>

I hope someone can help me…cause i need to solve it urgently…

I tried to search solution and when I tried like the editing php.ini, it did not work.

Thank you

How do you know the xml file was uploaded correctly?

but still i cannot import my .xml files.

no error displayed so i cannot configured out.

So what does happen? A timeout? A blank page?

it was a blank page…

at the end of my import.php
i have this:


<html>
  <body>
  
  <table>
  <tr>
      <th>Employee Attendance</th>
  </tr>

  <?php foreach( $data as $row ) { ?>
  <tr>
  <td><?php echo( $row['EMP_NO'] ); ?></td> 
  <td><?php echo( $row['DATE_DTR'] ); ?></td> 
  <td><?php echo( $row['DTR'] ); ?></td>
  </tr>
  <?php } ?>
  </table>
  </body>
 </html>

the output is only the

Employee Attendance

The data was not uploaded.

Is there any code should i used for importing files to mysql…like csv?

Thank you so much…

I resolved it by using this code:


if (empty($_FILES['file']['tmp_name']['error']))
  {
      $dom = DOMDocument::load('PayrollTest.xml');
     // $dom = DOMDocument::load($_FILES['file']['tmp_name']);   
      
      //ini_set('memory_limit', '150MB');   
      $rows = $dom->getElementsByTagName('Row');
      global $last_row;
      $last_row = false;
      $first_row = true;
      foreach ($rows as $row)
      {
          if ( !$first_row )
          {
              $EMP_NO = "";
              $Date = "";
              $DTR = "";
              
              $index = 1;
              $cells = $row->getElementsByTagName( 'Cell' );
          
              foreach( $cells as $cell )
              { 
                  $ind = $cell->getAttribute( 'Index' );
                  if ( $ind != null ) $index = $ind;
                  
                  if ( $index == 1 ) $EMP_NO = $cell->nodeValue;
                  if ( $index == 2 ) $Date = $cell->nodeValue;
                  if ( $index == 3 ) $DTR = $cell->nodeValue;
                  $index += 1;
              }
             if ($EMP_NO=='' and $Date=='' and $DTR=='') {
                    $last_row = true;
              }      
              else {
                    add_employee($EMP_NO, $Date, $DTR);

              }      
          }
          if ($last_row==true) {
              $first_row = true;
          }     
          else {
              $first_row = false;
          }
      }
  }
  else{
    echo 'There was an error uploading your file: '.$_FILES['file']['tmp_name']['error']; 
  }

Thank you