|
-
Jun 14th, 2007, 01:52 PM
#1
Lost connection to MySQL server during query [2013]
this is driving me nuts..
I had this working fine with phpbb3 and a mod called portal...
now, it wont work.. it seems like its timing out or something.
It an rss feed parser.. pulls them in and dumps them to the page
no matter where I call the class and pass in the feeds it fails.
Strange this is.. wherever i call it.. it will fail on the next sql query
here is the bb3portal which calls all the files to build the page
PHP Code:
<?php
$phpbb_root_path = './';
define('IN_PHPBB', true);
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'bb3portal/config.'.$phpEx);
include($phpbb_root_path . 'bb3portal/includes/functions.'.$phpEx);
$user->session_begin();
$auth->acl($user->data);
$user->setup('bb3portal');
include ($phpbb_root_path . 'bb3portal/block/rss_feeds.' . $phpEx);
include($phpbb_root_path . 'bb3portal/block/rss_feedlist.'.$phpEx);
// only registered user see blocks
if ($user->data['is_registered'])
{
//include($phpbb_root_path . 'bb3portal/block/online_friends.'.$phpEx);
include($phpbb_root_path . 'bb3portal/block/user_menu.'.$phpEx);
}
else
{
include($phpbb_root_path . 'bb3portal/block/login_box.'.$phpEx);
}
// other blocks
include($phpbb_root_path . 'shout.' . $phpEx);
include($phpbb_root_path . 'bb3portal/block/announcements.'.$phpEx);
include($phpbb_root_path . 'bb3portal/block/news.'.$phpEx);
include($phpbb_root_path . 'bb3portal/block/recent.'.$phpEx);
include($phpbb_root_path . 'bb3portal/block/stat_adv.'.$phpEx);
include($phpbb_root_path . 'bb3portal/block/whos_online.'.$phpEx);
include($phpbb_root_path . 'bb3portal/block/latest_members.'.$phpEx);
include($phpbb_root_path . 'bb3portal/block/random_member.'.$phpEx);
include($phpbb_root_path . 'bb3portal/block/most_poster.'.$phpEx);
include($phpbb_root_path . 'bb3portal/block/donate.'.$phpEx);
include($phpbb_root_path . 'bb3portal/block/search.'.$phpEx);
include($phpbb_root_path . 'bb3portal/block/link_us.'.$phpEx);
include($phpbb_root_path . 'bb3portal/block/leaders.'.$phpEx);
// output page
page_header($user->lang['PORTAL']);
$template->set_filenames(array(
'body' => 'bb3portal/portal_main.html')
);
make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
page_footer();
?>
here is the rss_feeds.php file (the class.. which i know works fine.. i can include this with no issues...
PHP Code:
<?php
class StaticFxRssFeed {
private $nr_news=5;
private $rss_channel = array();
private $currently_writing = "";
private $main = "";
private $item_counter = 0;
private $template;
private $feedname;
private $url;
function __construct($feedname, $url) {
$this->feedname = $feedname;
$this->url = $url;
}
function startElement($parser, $name, $attrs) {
switch($name) {
case "RSS":
case "RDF:RDF":
case "ITEMS":
$this->currently_writing = "";
break;
case "CHANNEL":
$this->main = "CHANNEL";
break;
case "IMAGE":
$this->main = "IMAGE";
$this->rss_channel["IMAGE"] = array();
break;
case "ITEM":
$this->main = "ITEMS";
break;
default:
$this->currently_writing = $name;
break;
}
}
function endElement($parser, $name) {
$this->currently_writing = "";
if ($name == "ITEM") {
$this->item_counter++;
}
}
function characterData($parser, $data) {
if ($this->currently_writing != "") {
switch($this->main) {
case "ITEMS":
if (isset($this->rss_channel[$this->main][$this->item_counter][$this->currently_writing])) {
$this->rss_channel[$this->main][$this->item_counter][$this->currently_writing] .= $data;
} else {
//print ("rss_channel[$main][$item_counter][$currently_writing] = $data<br>");
$this->rss_channel[$this->main][$this->item_counter][$this->currently_writing] = $data;
}
break;
}
}
}
function get_data(&$template) {
$xml_parser = xml_parser_create();
xml_set_element_handler(
$xml_parser,
array($this, 'startElement'),
array($this, 'endElement')
);
xml_set_character_data_handler(
$xml_parser,
array($this, 'characterData')
);
$data = self::curl_string($this->url);
xml_parse($xml_parser,$data);
xml_parser_free($xml_parser);
// putting in array
$news=array();
if (isset($this->rss_channel["ITEMS"]))
{
if (count($this->rss_channel["ITEMS"]) > 0)
for($i = 0;$i < count($this->rss_channel["ITEMS"]);$i++) $news[]=$this->rss_channel["ITEMS"][$i];
}
$c=0;
foreach($news as $key=>$val)
{
if($c<$this->nr_news)
{
$template->assign_block_vars($this->feedname, array(
'LINK' => isset($val['LINK']) ? $val['LINK'] : '',
'TITLE' => isset($val['TITLE']) ? $val['TITLE'] : '',
'DESC' => isset($val['DESCRIPTION']) ? $val['DESCRIPTION'] : '')
);
}
$c++;
}
}
private static function curl_string ($url,$user_agent='Mozilla 4.0'){
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_TIMEOUT, 2);
$result = curl_exec ($ch);
curl_close($ch);
return $result;
}
}
?>
and finally here is the rss_feedlist.php which passes in the urls for the feeds.
PHP Code:
<?php
class StaticFxRssFeed {
private $nr_news=5;
private $rss_channel = array();
private $currently_writing = "";
private $main = "";
private $item_counter = 0;
private $template;
private $feedname;
private $url;
function __construct($feedname, $url) {
$this->feedname = $feedname;
$this->url = $url;
}
function startElement($parser, $name, $attrs) {
switch($name) {
case "RSS":
case "RDF:RDF":
case "ITEMS":
$this->currently_writing = "";
break;
case "CHANNEL":
$this->main = "CHANNEL";
break;
case "IMAGE":
$this->main = "IMAGE";
$this->rss_channel["IMAGE"] = array();
break;
case "ITEM":
$this->main = "ITEMS";
break;
default:
$this->currently_writing = $name;
break;
}
}
function endElement($parser, $name) {
$this->currently_writing = "";
if ($name == "ITEM") {
$this->item_counter++;
}
}
function characterData($parser, $data) {
if ($this->currently_writing != "") {
switch($this->main) {
case "ITEMS":
if (isset($this->rss_channel[$this->main][$this->item_counter][$this->currently_writing])) {
$this->rss_channel[$this->main][$this->item_counter][$this->currently_writing] .= $data;
} else {
//print ("rss_channel[$main][$item_counter][$currently_writing] = $data<br>");
$this->rss_channel[$this->main][$this->item_counter][$this->currently_writing] = $data;
}
break;
}
}
}
function get_data(&$template) {
$xml_parser = xml_parser_create();
xml_set_element_handler(
$xml_parser,
array($this, 'startElement'),
array($this, 'endElement')
);
xml_set_character_data_handler(
$xml_parser,
array($this, 'characterData')
);
$data = self::curl_string($this->url);
xml_parse($xml_parser,$data);
xml_parser_free($xml_parser);
// putting in array
$news=array();
if (isset($this->rss_channel["ITEMS"]))
{
if (count($this->rss_channel["ITEMS"]) > 0)
for($i = 0;$i < count($this->rss_channel["ITEMS"]);$i++) $news[]=$this->rss_channel["ITEMS"][$i];
}
$c=0;
foreach($news as $key=>$val)
{
if($c<$this->nr_news)
{
$template->assign_block_vars($this->feedname, array(
'LINK' => isset($val['LINK']) ? $val['LINK'] : '',
'TITLE' => isset($val['TITLE']) ? $val['TITLE'] : '',
'DESC' => isset($val['DESCRIPTION']) ? $val['DESCRIPTION'] : '')
);
}
$c++;
}
}
private static function curl_string ($url,$user_agent='Mozilla 4.0'){
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_TIMEOUT, 2);
$result = curl_exec ($ch);
curl_close($ch);
return $result;
}
}
?>
then i get this error:
SQL ERROR [ mysqli ]
Lost connection to MySQL server during query [2013]
SQL
SELECT COUNT(post_id) as total FROM phpbb_posts WHERE post_time >= 1181765730
BACKTRACE
FILE: includes/db/mysqli.php
LINE: 118
CALL: dbal->sql_error()
FILE: bb3portal/block/user_menu.php
LINE: 27
CALL: dbal_mysqli->sql_query()
FILE: bb3portal.php
LINE: 42
CALL: include('bb3portal/block/user_menu.php')
note the last line.. i put the call to the feedlist before the user_menu is called and user menu fails... if I put the feed anywhere.. the next file fails
any ideas?
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|