Jump to content

Recommended Posts

Hi,

 

I have a very large multi-dimensional array to be inserted into MySQL database. It keeps up coming up with "MySQL server has gone away" error. I heard that I need to change the MySQL data limit but my hosting provider does not allow me to do so. I was thinking maybe input bit by bit but I wasn't 100% sure the best way of doing this. What is the best way do you think?

Link to comment
https://forums.phpfreaks.com/topic/222025-large-array-variable-insert-into-mysql/
Share on other sites

Below is the code and this is the site:

 

http://test6.favstay.com/

 

<?php
include ('db.php');
include ('mls.php');

soapImportNWMLS("Listing","Residential","2010-12-14T12:00:00","2010-12-14T23:59:59","","","","");

print_r($dataArray);

foreach($dataArray[RESI][Residential] as $data){


foreach($data as $key1 => $data1){
echo $key1." = ".$data1."<BR>";
$key2[] = "`".$key1."`";
$data2[] = "'".$data1."'";
}


$key1 =	mysql_real_escape_string(implode(", ",$key2));
$data1 = implode(", ",$data2);
echo "<br>".$key1."<br><br>";
echo $data1."<br><br>";
mysql_query("INSERT INTO RESI ($key1) VALUES($data1)")
or die(mysql_error());

}

?>

 

 

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.