Search code examples
phpxmlinishared-hosting

shared hosting CPanel linum godaddy


I have a shared hosting Cpanel Linux

I am trying to parse a XML file with over 3000 products in it.. I am getting a 500 Internal error while I am trying to parse it.. I go to "Select PHP version" through the Dashboard and "Switch to PHP Options" I have these settings: max_execution_time: 6000 memory_limit: 512M post_max_size 128MB upload_max_filesize 512MB

my file is almost 2MB so I guess the problem is not there.. The execution time stops the parsing at 2 minutes.. I have already upload a custom file php.ini with this inside: max_execution_time: 6000 I have also tried to upload a file named user.ini, with the same value.. but nothing works.. I have PHP version 5.6

the only value at 120 (seconds I guess) is this: realpath_cache_ttl but I do not know what this is... Any ideas please?

*In localhost xampp, I had the same problem, but by increasing the value of max_execution_time at 6000 the problem solved


Solution

  • ok I could not find any solution with godaddy.. They said everything are wokring fine in the server.. So, I tried to find a better optimized solution to my problem and I found the XMLReader:

    $reader = new XMLReader();
    $reader->open($product_xml_link);
        while($reader->read()) {
            if($reader->nodeType == XMLReader::ELEMENT && $reader->name == 'product' ) {
             //..do the proccess here..whatever you want..
             //for example
             $product = new SimpleXMLElement($reader->readOuterXml());
             $pid = $product->id;
             $name = $product->name;
            ...
            ...
    }
    

    There are lots of links that you could read of about XMLReader, which is also better for large XML files..

    Now, I could INSERT all the XML Elements into DB without any 500 internal errors. *Although my XML is not to big..about 3.500 products