cms_uploads Table - Cannot Import CSV

By Perchpole - April 15, 2014

Hello, All

I have started the rather daunting challenge of importing over 1000 products from X-cart into simpleCart. The process has been long and fiddly but I'm almost there. The only spanner in the works is the images!

There are 3000 pictures in total. I have compiled all the relevant data on a csv file but I cannot seem to import it into the cms_uploads table.

If I try through php I receive an error message: #2006 - MySQL server has gone away

If I try through the CSV import plugin it says the import is complete - but the table remains empty!

Please note I have sliced and diced the data in many different ways. I've tried importing everything from a single row of data to many hundreds. The results (above) are always the same.

I had none of these issues when importing the product data. Is cms_uploads a special case?

:0/

Perch

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