php - MySQL server has gone away error on server -
i have following code storing info arxiv.org pages in mysql
function paper_info($paper_id){ $url = 'http://arxiv.org/abs/'.$paper_id; $options = array('http'=>array('method'=>"get", 'header'=>"user-agent: mozilla/5.0 (windows nt 6.1; trident/7.0; rv:11.0) gecko\r\n")); $context = stream_context_create($options); $sites_html = file_get_contents($url, false, $context); $html = new domdocument(); @$html->loadhtml($sites_html); $title = null; foreach($html->getelementsbytagname('meta') $meta) { if($meta->getattribute("name")=="citation_title"){ $title = $meta->getattribute('content'); } } if(preg_match('~<blockquote class="abstract mathjax">(.*?)</blockquote>~si', $sites_html, $match)){ $abstract = trim(preg_replace('#<span class="descriptor">(.*?)</span>#', '', $match[1])); } return array($title, $abstract); } $paper_id = "1509.05363v1"; if(!isset($paper_info)) $paper_info = paper_info($paper_id); mysql_query("insert `data` (`id`, `action`, `value`) values (null, 'submit', '0');"); mysql_query("insert `data` (`id`, `action`, `value`) values (null, 'paper id', '".$paper_id."');"); mysql_query("insert `data` (`id`, `action`, `value`) values (null, 'title', '".mysql_real_escape_string($paper_info[0])."');"); mysql_query("insert `data` (`id`, `action`, `value`) values (null, 'abstract', '".mysql_real_escape_string($paper_info[1])."');");
the code works fine on localhost however, when uploaded site on online server error happens
mysql server has gone away
i tried increasing max_allowed_packet
suggested in mysql error 2006: mysql server has gone away adding line
mysql_query("set global max_allowed_packet = 1073741824;");
but error still happens. know why happens?
after trying
mysql_query("set session wait_timeout = 300;"); mysql_query("set global interactive_timeout=300;"); mysql_query("set global wait_timeout=300;");
the error doesn't happen function paper_info
return empty value on server works fine on localhost. why happening?
have tried setting wait_timeout , interactive_timeout
value?
example:
set global wait_timeout=300; set global interactive_timeout=300;
Comments
Post a Comment