cms_uploads Table - Cannot Import CSV

By gregThomas - April 15, 2014

Hi Perch,

I'm guessing you resolved this issue if you've successfully imported all of the records?

The issue is caused by your server dropping the MySQL connection to the page after a few seconds if it hasn't carried out any requests. As it assumes that the page doesn't need to make any calls (I guess this might be happening while your script downloads images).

You can get the script to reconnect to MySQL with the following code:

 if (!mysql_ping()) { // check if we're still connected and detect "MySQL server has gone away" timeout errors
  //mysql_close(); // if needed - close connect to ensure it gets recreated correctly (even if connection isn't working!)
  $GLOBALS['DBH'] = @mysql_connect($GLOBALS['SETTINGS']['mysql']['hostname'], $GLOBALS['SETTINGS']['mysql']['username'], $GLOBALS['SETTINGS']['mysql']['password'], true);
  if (!$GLOBALS['DBH']) { die("Error re-connecting to MySQL: $connectionError"); }
  mysql_select_db($GLOBALS['SETTINGS']['mysql']['database']);
}

So you'd put this code just after any extremely time consuming tasks. It will check the connection and reconnect if it's been dropped.

Let me know if you have any questions.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By Perchpole - April 15, 2014

Hi, Greg -

The csv hardly contained any data - other than the names of the images, their related record - and their dimensions. The other 25 columns were either blank or contained "0".

That said there were almost 3,000 rows!

It proved impossible to import this data into the live database. It wouldn't work in phpMyAdmin nor your own CSV Import (which got very fussy!).

In the end I simply created a new cms_uploads table from scratch on my localhost computer - exported it as an SQL file - then created a new table with it on the live server.

It seems to have taken forever - but it was a good learning experience.

:0)

Perch