Jump to content

Large array variable insert into MySQL


hybmg57

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());

}

?>

 

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.