"Mysql has gone away" heavy multiple insert I am stuck because Mysql server will go away after executing this part of code this function will update the database with the new RSS feeds which are stored in ToUpdate but Mysql stops working. Every cell of the array contains a long string for description,for example at the size of 3000 words or more and may be that's the problem. the maximum size of $this->array_counter is less than 30 and is set before in another function. after running the function after 3 to 6 inserts mysql says " mysql has gone away". Is the problem related to connection limit or bandwidth limit or fast inserting?

function update_db()
{


    for($i = 0;$i &lt; $this-&gt;array_counter ; $i++ ){

        $url=$this-&gt;toUpdate[$i]['url'];

         $t=addslashes( $this-&gt;toUpdate[$i]['title'] );
         $t=$this-&gt;convert_line_breaks($t,"&lt;br/&gt;");

         $d=addslashes( $this-&gt;toUpdate[$i]['desc'] );
         $d= $this-&gt;convert_line_breaks($d,"&lt;br/&gt;");

         $date= $this-&gt;toUpdate[$i]['date'];

    //echo "&lt;fieldset&gt;".$url."&lt;br/&gt;".$t."&lt;br/&gt;".$d."&lt;/fieldset&gt;";

        $r=mysql_query("INSERT INTO feed_items(items_id,items_title,items_url,items_description,items_date,feed_id,like_hits) VALUES('','$t','$u','$d','$date','$this-&gt;Feed_id','0') ",$this-&gt;dblink)or die(mysql_error());

    }//end of foreach
}
I usually blame the size of your MySQL Packet

I have written past posts on this


Sep 01, 2011 : MySQL server has gone away obstructing import of large dumps
Sep 25, 2011 : Fixing MySQL errors recorded in error logs
Jun 12, 2012 : MySQL Error Reading Communication Packets


Just raise your MySQL Packet size (max_allowed_packet) in /etc/my.cnf

[mysqld]
max_allowed_packet=256M


and restart mysql