0

I have a large xml file (60Mb) that I want to parse and insert each record in MySQL DB. I'm using simpleXML to do so and worked like a charm in Xamp but does not on live hosted website. I get no errors so I dont know why the $xml object keeps returning false. Is it becacause of the large amount of records in the XML?

require('connectDB.php');
$query = "INSERT INTO myTable (cp,colonia,municipio,ciudad,estado) VALUES (?,?,?,?,?)";
if($stm = $con->prepare($query)){
    if(file_exists('CPdescarga.xml')){
        $xml = simplexml_load_file("CPdescarga.xml", 'SimpleXMLElement', LIBXML_COMPACT | LIBXML_PARSEHUGE);
        if($xml === false){
            echo "No se cargó el archivo correctamente";
            foreach (libxml_get_errors() as $error){
                echo "\t". $error->message;
            }  
        } else{
            $error = 0;
            foreach($xml->table AS $registro){
                $stm->bind_param('sssss',$registro->d_codigo,$registro->d_asenta,$registro->D_mnpio,$registro->d_ciudad,$registro->d_estado);
                if(!$stm->execute()){
                    $error++;
                } 
            }
        echo "Se presentaron $error errores!";
        }

    } else{
        echo "No existe el archivo!";
    } 

} else{
    echo "No se pudo preparar la consulta";
}
$stm->close();
$con->close();`

XML file

  • Please use the instructions on this answer to find your error message, read it carefully, and post a new question if you cannot solve it. http://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php/12772851#12772851 – IMSoP Aug 30 '16 at 16:19
  • did you get any solution for that ? – Dhaval Vaghela Feb 08 '18 at 06:27
  • Yes, "Try checking the following values in your php.ini on your server (use phpinfo() function to display): post_max_size and upload_max_filesize" was correct. – Elias Zarte Feb 08 '18 at 20:00

1 Answers1

0

Try checking the following values in your php.ini on your server (use phpinfo() function to display): post_max_size and upload_max_filesize

Increase them both if necessary. see here: http://php.net/manual/en/ini.core.php

Arthur Nicoll
  • 391
  • 1
  • 2
  • 8