1

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 < $this->array_counter ; $i++ ){

        $url=$this->toUpdate[$i]['url'];

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

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

         $date= $this->toUpdate[$i]['date'];

    //echo "<fieldset>".$url."<br/>".$t."<br/>".$d."</fieldset>";

        $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->Feed_id','0') ",$this->dblink)or die(mysql_error());

    }//end of foreach
}

1 Answer 1

2

I usually blame the size of your MySQL Packet

I have written past posts on this

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

[mysqld]
max_allowed_packet=256M

and restart mysql

4
  • Thank you very much,but my problem is that I am on a shared hosting and I don't know if I can do this or not.
    – user539656
    Commented Aug 15, 2012 at 8:45
  • Are you using Amazon RDS ??? Commented Aug 15, 2012 at 11:32
  • No I am using simple hosting which is shared hosting
    – user539656
    Commented Aug 27, 2012 at 16:56
  • @RolandoMySQLDBA Rolando, what happens when this is not related to to the max_allowed_packet size? I've increased my to 1G and still my server crashes after the 2nd iteration of the loop. None of my fields contain more than about 50 characters, and my tables have no more than 3 columns and 1 join. However some of my inserts contain 50 thousand rows, and this cannot be split up. How would one deal with that?
    – user658182
    Commented Jul 4, 2013 at 8:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.