You are invited to Log in or Register a free Frihost Account!

Weird php script behavior

I have an ajax script that calls some PHPExcel libraries to parse an xlsx document and to introduce it into a database. The xlsx file could be up to 30000 lines long.

I write on the page one line for each imported line into the database, however I have two strange behaviors.

First, no matter I call ajax sync of async, the script only shows the list of processed lines at the end.
Second, If I don't print a long line (like the sql insert) the script stops at 10300 lines processed, when I print the sql insert, it finishes without problem at 30000 lines.

This is very strange to me, Does anyone has an idea of why does it happen?

How long does it take to process the file. By default a PHP script has a maximum execution time of about 60 seconds before it self terminates the script. Use the set_time_limit() function (I'd use it inside a loop) to give yourself more time.

It's also possible that the web server is closing the connection and the PHP script is still processing the file

There could be an error message that isn't reported in the output. You could check the error log.

For ajax it might help to use a packet sniffer like wireshark to examine the network traffic to verify that the php script is the problem.

Another things I'd try is
. add a flush() and the end of the loop
. have the program write the same output to a file to see if it too is incorrect later.
. upload the excel file on the server, Copy the code to a new script and set it up to process that file so you can call it directly in the browser and repeatedly process that file with various kinds of verbosity until you figure out what's wrong or how it's doing something wrong.
hi have you tried xls files? not xlsx.. most of the new office files don't work on libraries.. maybe you will have to convert your file or save it as a 2000-2005 excel file
Related topics
Phoenix free PHP scripts
error in my PHP script
how can i make a php script for enter username and password?
Inserting data to MYSQL with a PHP script
Running a "Hello World" php script
[PHP] Running Cron Jobs Via PHP Script
Simple PHP script not working
PHP Script- How can we install it
I need a VERY simple php script
PHP Script needed
Logging systeem php script
Preventing bad PHP script calls
array check box on php script using $_POST
How to change extension php to html but the php script still
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

© 2005-2011 Frihost, forums powered by phpBB.