Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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
}
share|improve this question
add comment

1 Answer

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

share|improve this answer
    
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 Aug 15 '12 at 8:45
    
Are you using Amazon RDS ??? –  RolandoMySQLDBA Aug 15 '12 at 11:32
    
No I am using simple hosting which is shared hosting –  user539656 Aug 27 '12 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 Jul 4 '13 at 8:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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