Need Help with a Fatal Error on my Link Directory...

Discussion in 'PHP' started by Pixel Dynamics, Nov 6, 2006.

  1. #1
    Hello Everyone,

    I went to bed last night, and my directory was working fine... I woke up this morning, and it is displaying this message:

    Fatal error: Call to a member function FetchRow() on a non-object in /home/xfactor4/public_html/index.php on line 159

    The URL is:
    http://www.linkseeker.net

    Does anyone know what could have happend, and or how to fix it?

    Thanks in advance,
    - Nick
     
    Pixel Dynamics, Nov 6, 2006 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Try setting this at the top of your index page.

    
    error_reporting(E_ALL);
    
    Code (markup):
    The code has no reason to stop working from one day to the next. Something has changed. I hope the error reporting will tell us more. Also it would help a lot if you could post your code.
     
    nico_swd, Nov 6, 2006 IP
  3. Pixel Dynamics

    Pixel Dynamics Active Member

    Messages:
    809
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Alright, well i tried that. But it didnt show anything diffrent... 159 changed to 162...

    Ill post the code in a sec.

    Thanks,

    THE CODE:

    <?php
    
    error_reporting(E_ALL);
    
    /**
     * Project:     PHPLinkDirectory: Link exchange directory
     *
     * License: GNU GPL (http://www.opensource.org/licenses/gpl-license.html)
     * 
     * This program is free software;
     * 
     * you can redistribute it and/or modify it under the terms of the GNU General Public License
     * as published by the Free Software Foundation; either version 2 of the License,
     * or (at your option) any later version.
     *
     * This program is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
     *
     * You should have received a copy of the GNU General Public License along with this program;
     * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
     *
     * For questions, help, comments, discussion, etc., please join the
     * PHP Link Directory Forum http://www.phplinkdirectory.com/forum/
    
     *
     * @link http://www.phplinkdirectory.com/
     * @copyright 2004-2005 NetCreated, Inc. (http://www.netcreated.com/)
     * @projectManager David DuVal <david@david-duval.com>
     * @author Bogdan Dumitru <dcb@insomniacsoft.com>
     * @mod developers and support
     * 		Casey Wilson / Ap0s7le <at@ap0s7le.com>
     * 		York Kie Tan / yktan <yktan@hotmail.com>
     * @package PHPLinkDirectory
     * @version 2.0.0 RC5.2
     **/
     
    require_once 'init.php';
    define('DIR_LPP', 20);
    $sort_cols = array ( 'P' => 'PAGERANK', 'H' => 'HITS', 'A' => 'TITLE');
    $sort_ord = array ( 'P' => 'DESC', 'H' => 'DESC', 'A' => 'ASC');
    
    //	Paging 1
    $page = preg_match('`\d+`', $_REQUEST['p']) ? $_REQUEST['p'] : 1;
    
    	if ($page != 1)
    	{
    		$min = PAGER_LPP * $page - (PAGER_LPP);
    		$max = PAGER_LPP * $page;
    	}
    	else
    	{
    		$min = 0;
    		$max = PAGER_LPP;
    	}
    	$limit = " LIMIT {$min}," . PAGER_LPP;
    //	End Paging 1
    
    if(array_key_exists($_REQUEST['s'], $sort_cols)){
    	$sort = $_REQUEST['s'];
    }else{
    	$sort = DEFAULT_SORT;
    }
    if(!ENABLE_PAGERANK || !SHOW_PAGERANK && $sort == 'P')
    	$sort = 'H';
    $tpl->assign('sort', $sort);
    $path = array();
    $path[] = array ('ID' => '0', 'TITLE' => _L(SITE_NAME), 'TITLE_URL' => DOC_ROOT, 'DESCRIPTION' => SITE_DESC);
    if(FTR_ENABLE){
    	$feat_where = 'AND (FEATURED = 0)';
    }
    $expire_where = "AND (EXPIRY_DATE>=".$db->DBDate(time())." OR EXPIRY_DATE IS NULL)";
    if (isset($_REQUEST['p'])){
    	switch($_REQUEST['p']){
    		case 'd':
    			$links = $db->GetAll("SELECT * FROM {$tables['link']['name']} WHERE STATUS=2 $expire_where ORDER BY DATE_ADDED desc limit 0, ".LINKS_TOP);
    			$path[] = array ('ID' => '0', 'TITLE' => _L('Latest Links'), 'TITLE_URL' => '', 'DESCRIPTION' => '');
    			break;
    		case 'h':
    			$links = $db->GetAll("SELECT * FROM {$tables['link']['name']} WHERE STATUS=2 $expire_where ORDER BY hits desc limit 0, ".LINKS_TOP);
    			$path[] = array ('ID' => '0', 'TITLE' => _L('Top Hits'), 'TITLE_URL' => '', 'DESCRIPTION' => '');
    			break;
    		// Paging 2
    		default:
    			$id = get_category();
    	if (!$tpl->is_cached('main.tpl', $id)) {
    		$path = get_path($id);
    		if(FTR_ENABLE){
    			$feat_links = $db->GetAll("SELECT * FROM {$tables['link']['name']} WHERE STATUS=2 AND CATEGORY_ID = $id AND FEATURED=1 $expire_where ORDER BY EXPIRY_DATE DESC");
    			$tpl->assign('feat_links', $feat_links);
    		}
    		
    		$count = $db->GetAll("SELECT * FROM {$tables['link']['name']} WHERE STATUS=2 AND CATEGORY_ID = $id $feat_where $expire_where ORDER BY {$sort_cols[$sort]} {$sort_ord[$sort]}");
    
    		$links = $db->GetAll("SELECT * FROM {$tables['link']['name']} WHERE STATUS=2 AND CATEGORY_ID = $id $feat_where $expire_where ORDER BY {$sort_cols[$sort]} {$sort_ord[$sort]}{$limit}");
    		$rs = $db->Execute("SELECT * FROM {$tables['category']['name']} WHERE STATUS=2 AND PARENT_ID = $id ORDER BY TITLE");
    		while (!$rs->EOF) {
    			$row = $rs->FetchRow();
    			if ($id == 0 && CATS_PREVIEW > 0) {
    				$rs2 = $db->SelectLimit("SELECT * FROM {$tables['category']['name']} WHERE STATUS=2 AND SYMBOLIC <> 1 AND PARENT_ID = ".$row['ID']." ORDER BY HITS DESC, TITLE", CATS_PREVIEW);
    				$row['SUBCATS'] = $rs2->GetRows();
    				$rs2->Close();
    			}
    			if (ENABLE_REWRITE && empty ($row['TITLE_URL'])) {
    				$row['TITLE_URL'] = preg_replace('`[^\w_-]`', '_', $row['TITLE']);
    				$row['TITLE_URL'] = str_replace('__', '_', $row['TITLE_URL']);
    			}
    			$row['COUNT'] = $db->GetOne("SELECT COUNT(*) FROM {$tables['category']['name']} WHERE STATUS=2 AND PARENT_ID = ".$row['ID']);
    
    			$row['COUNT'] += $db->GetOne("SELECT COUNT(*) FROM {$tables['link']['name']} WHERE STATUS=2 AND CATEGORY_ID = ".$row['ID']);
    			if ($row['SYMBOLIC'] == 1) {
    				$row['ID'] = $row['SYMBOLIC_ID'];
    				$tempcat = $db->GetRow("SELECT * FROM ".$tables['category']['name']." WHERE ID = ".$db->qstr($row['SYMBOLIC_ID']));
    				if (empty($row['TITLE'])) {
    					$row['TITLE'] = $tempcat['TITLE'];
    				}
    				$row['TITLE'] = "@" . $row['TITLE'];
    			}
    
    			$categs[] = $row;
    		}
    		$rs->Close();
    	}
    //		$count = $db->GetAll("SELECT * FROM {$tables['link']['name']} WHERE STATUS=2 AND CATEGORY_ID = {$id}");
    		$links = $db->GetAll("SELECT * FROM {$tables['link']['name']} WHERE STATUS=2 AND CATEGORY_ID = {$id} $feat_where $expire_where ORDER BY {$sort_cols[$sort]} {$sort_ord[$sort]}{$limit}");
    		$path = get_path($id);
    
    		$path[] = array ('ID' => $id, 'TITLE' => _L('Page ' . $page), 'TITLE_URL' => '', 'DESCRIPTION' => '');
    
    			break;
    		// End Paging 2
    	}
    	$tpl->assign('p', $_REQUEST['p']);
    
    }elseif (isset ($_REQUEST['q'])) {
    	$q = $db->qstr('%'.preg_replace('`\s+`','%', $_REQUEST['q']).'%');
    	if(FTR_ENABLE){
    		$feat_links = $db->GetAll("SELECT * FROM {$tables['link']['name']} WHERE STATUS=2 AND (URL LIKE $q OR TITLE LIKE $q OR DESCRIPTION LIKE $q) AND FEATURED=1 $expire_where ORDER BY EXPIRY_DATE DESC");
    		$tpl->assign('feat_links', $feat_links);
    	}
    	$links = $db->GetAll("SELECT * FROM {$tables['link']['name']} WHERE STATUS=2 AND (URL LIKE $q OR TITLE LIKE $q OR DESCRIPTION LIKE $q) $feat_where $expire_where ORDER BY {$sort_cols[$sort]} {$sort_ord[$sort]}");
    	$categs = array();
    	$path[] = array ('ID' => '0', 'TITLE' => _L('Search Results'), 'TITLE_URL' => '', 'DESCRIPTION' => _L('Search results for: ').$_REQUEST['q']);
    	$tpl->assign('qu', rawurlencode($_REQUEST['q']));
    	
    } else {
    	$id = get_category();
    	if (!$tpl->is_cached('main.tpl', $id)) {
    		$path = get_path($id);
    		if(FTR_ENABLE){
    			$feat_links = $db->GetAll("SELECT * FROM {$tables['link']['name']} WHERE STATUS=2 AND CATEGORY_ID = $id AND FEATURED=1 $expire_where ORDER BY EXPIRY_DATE DESC");
    			$tpl->assign('feat_links', $feat_links);
    		}
    		
    		// Paging 3
    		$count = $db->GetAll("SELECT * FROM {$tables['link']['name']} WHERE STATUS=2 AND CATEGORY_ID = $id $feat_where $expire_where ORDER BY {$sort_cols[$sort]} {$sort_ord[$sort]}");
    		// End Paging 3
    
    		$links = $db->GetAll("SELECT * FROM {$tables['link']['name']} WHERE STATUS=2 AND CATEGORY_ID = $id $feat_where $expire_where ORDER BY {$sort_cols[$sort]} {$sort_ord[$sort]}{$limit}");
    		$rs = $db->Execute("SELECT * FROM {$tables['category']['name']} WHERE STATUS=2 AND PARENT_ID = $id ORDER BY TITLE");
    		while (!$rs->EOF) {
    			$row = $rs->FetchRow();
    			if ($id == 0 && CATS_PREVIEW > 0) {
    				$rs2 = $db->SelectLimit("SELECT * FROM {$tables['category']['name']} WHERE STATUS=2 AND SYMBOLIC <> 1 AND PARENT_ID = ".$row['ID']." ORDER BY HITS DESC, TITLE", CATS_PREVIEW);
    				$row['SUBCATS'] = $rs2->GetRows();
    				$rs2->Close();
    			}
    			if (ENABLE_REWRITE && empty ($row['TITLE_URL'])) {
    				$row['TITLE_URL'] = preg_replace('`[^\w_-]`', '_', $row['TITLE']);
    				$row['TITLE_URL'] = str_replace('__', '_', $row['TITLE_URL']);
    			}
    			$row['COUNT'] = $db->GetOne("SELECT COUNT(*) FROM {$tables['category']['name']} WHERE STATUS=2 AND PARENT_ID = ".$row['ID']);
    
    			$row['COUNT'] += $db->GetOne("SELECT COUNT(*) FROM {$tables['link']['name']} WHERE STATUS=2 AND CATEGORY_ID = ".$row['ID']);
    			if ($row['SYMBOLIC'] == 1) {
    				$row['ID'] = $row['SYMBOLIC_ID'];
    				$tempcat = $db->GetRow("SELECT * FROM ".$tables['category']['name']." WHERE ID = ".$db->qstr($row['SYMBOLIC_ID']));
    				if (empty($row['TITLE'])) {
    					$row['TITLE'] = $tempcat['TITLE'];
    				}
    				$row['TITLE'] = "@" . $row['TITLE'];
    			}
    
    			$categs[] = $row;
    		}
    		
    		$rs->Close();
    	}
    	if ($id > 0)
    		$db->Execute("UPDATE {$tables['category']['name']} SET HITS=HITS+1 WHERE ID=$id");
    }
    
    // Paging 4
    $tpl->assign('list_total', count($count));
    // End Paging 4
    
    $tpl->assign('category', $path[count($path) - 1]);
    $tpl->assign('path', $path);
    $tpl->assign('links', $links);
    $tpl->assign('categs', $categs);
    echo $tpl->fetch('main.tpl', $id);
    
    ?>
    
    Code (markup):
     
    Pixel Dynamics, Nov 6, 2006 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    Try chaning $rs to $db (line 162 with the error_reporting() )

    
    while (!$rs->EOF) {
     $row = $db->FetchRow();
    
    PHP:
     
    nico_swd, Nov 6, 2006 IP
  5. Pixel Dynamics

    Pixel Dynamics Active Member

    Messages:
    809
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    60
    #5
    I tried, didnt make a diffrence... But I can't see that being the problem? Why would that have changed overnight?

    Also, $rs is used in several places... My directory has people constantly adding link... The only thing that changes is links being added to the database...

    Thank alot,
    - Nick
     
    Pixel Dynamics, Nov 6, 2006 IP
  6. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Maybe one of the source files is corrupted? Have you tried just uploading the code again?
     
    TwistMyArm, Nov 6, 2006 IP
  7. PinotNoir

    PinotNoir Peon

    Messages:
    505
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    0
    #7
    It's probably not anything with the script. I had this problem constantly until I changed hosts. There is likely a database failure on the server. Hope you are not using Dot5hosting, because they suck. I switched and now everything runs smoothly.
     
    PinotNoir, Nov 6, 2006 IP
  8. Pixel Dynamics

    Pixel Dynamics Active Member

    Messages:
    809
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    60
    #8
    Hrm... alright... Well I tried re-loading the files, no luck...

    I use www.asthost.com.

    Ill send a e-mail to them.

    Regards,
    - Nick
     
    Pixel Dynamics, Nov 6, 2006 IP