You are missing our premiere tool bar navigation system! Register and use it for FREE!

NukeCops  
•  Home •  Downloads •  Gallery •  Your Account •  Forums • 
Readme First
- Readme First! -

Read and follow the rules, otherwise your posts will be closed
Modules
· Home
· FAQ
· Buy a Theme
· Advertising
· AvantGo
· Bookmarks
· Columbia
· Community
· Donations
· Downloads
· Feedback
· Forums
· PHP-Nuke HOWTO
· Private Messages
· Search
· Statistics
· Stories Archive
· Submit News
· Surveys
· Theme Gallery
· Top
· Topics
· Your Account
Who's Online
There are currently, 62 guest(s) and 1 member(s) that are online.

You are Anonymous user. You can register for free by clicking here
Nuke Cops :: View topic - FAQ mysql_fetch_row(): error [ ]
 Forum FAQ  •  Search  •   •  Memberlist  •  Usergroups   •  Register  •  Profile •    •  Log in to check your private messages  •  Log in

 
This forum is locked: you cannot post, reply to, or edit topics.  This topic is locked: you cannot edit posts or make replies.printer-friendly view
View previous topic Log in to check your private messages View next topic
Author Message
Guest







PostPosted: Thu Feb 05, 2004 3:42 am Reply with quoteBack to top

Everything seems to be working fine except my FAQ section. When I'm in admin and try to add or edit anything in the FAQ module I see this error:

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/xscptwxl/public_html/includes/sql_layer.php on line 286

As a result I can't do anything with the module. Help!
Find all posts by Anonymous
xgate32
Corporal
Corporal


Joined: Aug 23, 2003
Posts: 63

Location: Korea, South

PostPosted: Thu Feb 05, 2004 4:53 am Reply with quoteBack to top

use debug mode, then you will find problem.
backup your sql_layer.php

use this
Code:

<?php

/************************************************************************/
/* PHP-NUKE: Web Portal System                                          */
/* ===========================                                          */
/*                                                                      */
/* Copyright (c) 2002 by Francisco Burzi                                */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* postgres fix by Rub? Campos - Oscar Silla                         */
/*                                                                      */
/* 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.       */
/************************************************************************/

if (eregi("sql_layer.php",$_SERVER['PHP_SELF'])) {
    Header("Location: ../index.php");
    die();
}

/* $dbtype = "MySQL"; */
/* $dbtype = "mSQL"; */
/* $dbtype = "postgres"; */
/* $dbtype = "postgres_local";// When postmaster start without "-i" option. */
/* $dbtype = "ODBC"; */
/* $dbtype = "ODBC_Adabas"; */
/* $dbtype = "Interbase"; */
/* $dbtype = "Sybase"; */

/*
 * sql_connect($host, $user, $password, $db)
 * returns the connection ID
 */


class ResultSet {
   var $result;
   var $total_rows;
   var $fetched_rows;

   function set_result( $res ) {
      $this->result = $res;
   }

   function get_result() {
      return $this->result;
   }

   function set_total_rows( $rows ) {
      $this->total_rows = $rows;
   }

   function get_total_rows() {
      return $this->total_rows;
   }

   function set_fetched_rows( $rows ) {
      $this->fetched_rows = $rows;
   }

   function get_fetched_rows() {
      return $this->fetched_rows;
   }

   function increment_fetched_rows() {
      $this->fetched_rows = $this->fetched_rows + 1;
   }
}



function sql_connect($host, $user, $password, $db)
{
global $dbtype;
switch ($dbtype) {

    case "MySQL":
        $dbi=@mysql_connect($host, $user, $password);
   mysql_select_db($db);
        return $dbi;
    break;;

    case "mSQL":
         $dbi=msql_connect($host);
    msql_select_db($db);
    return $dbi;
    break;;


    case "postgres":
         $dbi=@pg_connect("host=$host user=$user password=$password port=5432 dbname=$db");
         return $dbi;
    break;;

    case "postgres_local":
         $dbi=@pg_connect("user=$user password=$password dbname=$db");
         return $dbi;
    break;;

    case "ODBC":
         $dbi=@odbc_connect($db,$user,$password);
         return $dbi;
    break;;

    case "ODBC_Adabas":
         $dbi=@odbc_connect($host.":".$db,$user,$password);
    return $dbi;
    break;;

    case "Interbase":
         $dbi=@ibase_connect($host.":".$db,$user,$password);
         return $dbi;
    break;;

    case "Sybase":
        $dbi=@sybase_connect($host, $user, $password);
       sybase_select_db($db,$dbi);
   return $dbi;
    break;;

    default:
    break;;
    }

}

function sql_logout($id)
{
global $dbtype;
switch ($dbtype) {

    case "MySQL":
        $dbi=@mysql_close($id);
        return $dbi;
    break;;

    case "mSQL":
         $dbi=@msql_close($id);
         return $dbi;
    break;;

    case "postgres":
    case "postgres_local":
         $dbi=@pg_close($id);
         return $dbi;
    break;;
 
    case "ODBC":
    case "ODBC_Adabas":
         $dbi=@odbc_close($id);
         return $dbi; 
    break;;

    case "Interbase":
         $dbi=@ibase_close($id);
         return $dbi;
    break;;

    case "Sybase":
        $dbi=@sybase_close($id);
        return $dbi;
    break;;

    default:
    break;;
    }
}


/*
 * sql_query($query, $id)
 * executes an SQL statement, returns a result identifier
 */

function sql_query($query, $id)
{

global $dbtype;
global $sql_debug;
$sql_debug = 0;
if($sql_debug) echo "SQL query: ".str_replace(",",", ",$query)."<BR>";
switch ($dbtype) {

    case "MySQL":
        $res=@mysql_query($query, $id);
        if (mysql_errno()) { echo mysql_error()."<br>"; }
        return $res;
    break;;

    case "mSQL":
        $res=@msql_query($query, $id);
        return $res;
    break;;

    case "postgres":
    case "postgres_local":
   $res=pg_exec($id,$query);
   $result_set = new ResultSet;
   $result_set->set_result( $res );
   $result_set->set_total_rows( sql_num_rows( $result_set ) );
   $result_set->set_fetched_rows( 0 );
        return $result_set;
    break;;

    case "ODBC":
    case "ODBC_Adabas":
        $res=@odbc_exec($id,$query);
        return $res;
    break;;

    case "Interbase":
        $res=@ibase_query($id,$query);
        return $res;
    break;;

    case "Sybase":
        $res=@sybase_query($query, $id);
        return $res;
    break;;

    default:
    break;;

    }
}

/*
 * sql_num_rows($res)
 * given a result identifier, returns the number of affected rows
 */

function sql_num_rows($res)
{
global $dbtype;
switch ($dbtype) {
 
    case "MySQL":
        $rows=mysql_num_rows($res);
        if (mysql_errno()) { echo mysql_error()."<br>"; }
        return $rows;
    break;;

    case "mSQL": 
        $rows=msql_num_rows($res);
        return $rows;
    break;;

    case "postgres":
    case "postgres_local":
        $rows=pg_numrows( $res->get_result() );
        return $rows;
    break;;
       
    case "ODBC":
    case "ODBC_Adabas":
        $rows=odbc_num_rows($res);
        return $rows;
    break;;
       
    case "Interbase":
   echo "<BR>Error! PHP dosen't support ibase_numrows!<BR>";
        return $rows;
    break;;

    case "Sybase":
        $rows=sybase_num_rows($res);
        return $rows;
    break;;

    default:
    break;;
    }
}

/*
 * sql_fetch_row(&$res,$row)
 * given a result identifier, returns an array with the resulting row
 * Needs also a row number for compatibility with postgres
 */

function sql_fetch_row(&$res, $nr=0)
{
global $dbtype;
switch ($dbtype) {

    case "MySQL":
        $row = mysql_fetch_row($res);
        if (mysql_errno()) { echo mysql_error()."<br>"; }
        return $row;
    break;;

    case "mSQL":
        $row = msql_fetch_row($res);
        return $row;
    break;;

    case "postgres":
    case "postgres_local":
   if ( $res->get_total_rows() > $res->get_fetched_rows() ) {
      $row = pg_fetch_row($res->get_result(), $res->get_fetched_rows() );
      $res->increment_fetched_rows();
      return $row;
   } else {
      return false;
   }
    break;;

    case "ODBC":
    case "ODBC_Adabas":
        $row = array();
        $cols = odbc_fetch_into($res, $nr, $row);
        return $row;
    break;;

    case "Interbase":
        $row = ibase_fetch_row($res);
        return $row;
    break;;

    case "Sybase":
        $row = sybase_fetch_row($res);
        return $row;
    break;;

    default:
    break;;
    }
}

/*
 * sql_fetch_array($res,$row)
 * given a result identifier, returns an associative array
 * with the resulting row using field names as keys.
 * Needs also a row number for compatibility with postgres.
 */

function sql_fetch_array(&$res, $nr=0)
{
global $dbtype;
switch ($dbtype)
    {
    case "MySQL":
        $row = array();
        $row = mysql_fetch_array($res);
        if (mysql_errno()) { echo mysql_error()."<br>"; }
        return $row;
    break;;

    case "mSQL":
        $row = array();
        $row = msql_fetch_array($res);
        return $row;
    break;;

    case "postgres":
    case "postgres_local":
   if( $res->get_total_rows() > $res->get_fetched_rows() ) {
      $row = array();
      $row = pg_fetch_array($res->get_result(), $res->get_fetched_rows() );
      $res->increment_fetched_rows();
      return $row;
   } else {
      return false;
   }
    break;;

/*
 * ODBC doesn't have a native _fetch_array(), so we have to
 * use a trick. Beware: this might cause HUGE loads!
 */

    case "ODBC":
        $row = array();
        $result = array();
        $result = odbc_fetch_row($res, $nr);
   $nf = odbc_num_fields($res); /* Field numbering starts at 1 */
        for($count=1; $count < $nf+1; $count++)
   {
            $field_name = odbc_field_name($res, $count);
            $field_value = odbc_result($res, $field_name);
            $row[$field_name] = $field_value;
        }
        return $row;
    break;;

    case "ODBC_Adabas":
        $row = array();
        $result = array();
        $result = odbc_fetch_row($res, $nr);

        $nf = count($result)+2; /* Field numbering starts at 1 */
   for($count=1; $count < $nf; $count++) {
       $field_name = odbc_field_name($res, $count);
       $field_value = odbc_result($res, $field_name);
       $row[$field_name] = $field_value;
   }
        return $row;
    break;;

    case "Interbase":
   $orow=ibase_fetch_object($res);
   $row=get_object_vars($orow);
        return $row;
    break;;

    case "Sybase":
        $row = sybase_fetch_array($res);
        return $row;
    break;;

    }
}

function sql_fetch_object(&$res, $nr=0)
{
global $dbtype;
switch ($dbtype)
    {
    case "MySQL":
        $row = mysql_fetch_object($res);
        if (mysql_errno()) { echo mysql_error()."<br>"; }
   if($row) return $row;
   else return false;
    break;;

    case "mSQL":
        $row = msql_fetch_object($res);
   if($row) return $row;
   else return false;
    break;;

    case "postgres":
    case "postgres_local":
   if( $res->get_total_rows() > $res->get_fetched_rows() ) {
      $row = pg_fetch_object( $res->get_result(), $res->get_fetched_rows() );
      $res->increment_fetched_rows();
      if($row) return $row;
      else return false;
   } else {
      return false;
   }
    break;;

    case "ODBC":
        $result = odbc_fetch_row($res, $nr);
   if(!$result) return false;
   $nf = odbc_num_fields($res); /* Field numbering starts at 1 */
        for($count=1; $count < $nf+1; $count++)
   {
            $field_name = odbc_field_name($res, $count);
            $field_value = odbc_result($res, $field_name);
            $row->$field_name = $field_value;
        }
        return $row;
    break;;

    case "ODBC_Adabas":
        $result = odbc_fetch_row($res, $nr);
   if(!$result) return false;

        $nf = count($result)+2; /* Field numbering starts at 1 */
   for($count=1; $count < $nf; $count++) {
       $field_name = odbc_field_name($res, $count);
       $field_value = odbc_result($res, $field_name);
       $row->$field_name = $field_value;
   }
        return $row;
    break;;

    case "Interbase":
        $orow = ibase_fetch_object($res);
   if($orow)
   {
       $arow=get_object_vars($orow);
       while(list($name,$key)=each($arow))
       {
      $name=strtolower($name);
      $row->$name=$key;
       }
           return $row;
   }else return false;
    break;;

    case "Sybase":
        $row = sybase_fetch_object($res);
        return $row;
    break;;

    }
}

/*** Function Free Result for function free the memory ***/
function sql_free_result($res) {
global $dbtype;
switch ($dbtype) {

    case "MySQL":
        $row = mysql_free_result($res);
        if (mysql_errno()) { echo mysql_error()."<br>"; }
        return $row;
    break;;

      case "mSQL":
        $row = msql_free_result($res);
        return $row;
    break;;


       case "postgres":
    case "postgres_local":
        $rows=pg_FreeResult( $res->get_result() );
        return $rows;
    break;;

    case "ODBC":
    case "ODBC_Adabas":
        $rows=odbc_free_result($res);
        return $rows;
    break;;

    case "Interbase":
   echo "<BR>Error! PHP dosen't support ibase_numrows!<BR>";
        return $rows;
    break;;

    case "Sybase":
        $rows=sybase_free_result($res);
        return $rows;
    break;;
   }
}

?>

_________________
PHP-Nuke Korean Supoort Site!
http://phpnuke.happycgi.com
Find all posts by xgate32View user's profileSend private messageVisit poster's website
xgate32
Corporal
Corporal


Joined: Aug 23, 2003
Posts: 63

Location: Korea, South

PostPosted: Thu Feb 05, 2004 4:55 am Reply with quoteBack to top

This differ from original is

if (mysql_errno()) { echo mysql_error()."<br>"; }

_________________
PHP-Nuke Korean Supoort Site!
http://phpnuke.happycgi.com
Find all posts by xgate32View user's profileSend private messageVisit poster's website
havok
Nuke Soldier
Nuke Soldier


Joined: Dec 30, 2003
Posts: 20

Location: austin tx

PostPosted: Thu Feb 12, 2004 9:07 am Reply with quoteBack to top

I'm getting the same error, if anyone knows a fix for it.
Thanks
Phil
http://www.miniz.com
Find all posts by havokView user's profileSend private messageVisit poster's websiteAIM AddressYahoo MessengerICQ Number
Thraxus
Nuke Cadet
Nuke Cadet


Joined: Feb 12, 2004
Posts: 5


PostPosted: Sun Feb 15, 2004 6:00 pm Reply with quoteBack to top

Thanks xgate32. That debug version of sql_layer.php did the trick.

To those of you who haven't replaced your default sql_layer.php with the one posted above, I recommend you do. It was simple finding the problem afterward.

The fix (at least on my site):
In both /admin/modules/adminfaq.php & /modules/FAQ/index.php
Find all instances of faqCategories and replace with faqcategories

One letter with the wrong case and all hell breaks loose. Razz
Find all posts by ThraxusView user's profileSend private message
Chan1975
Nuke Soldier
Nuke Soldier


Joined: Feb 04, 2004
Posts: 12


PostPosted: Sun Feb 15, 2004 6:35 pm Reply with quoteBack to top

haha this is so funny. I did the fix like the above says. ok. Now I get a different error.
Find all posts by Chan1975View user's profileSend private message
sengsara
Support Staff
Support Staff


Joined: Sep 18, 2003
Posts: 289

Location: Batam, Indonesia (an hour boat ride from Singapore) ;)

PostPosted: Sun Feb 15, 2004 6:42 pm Reply with quoteBack to top

And the error is?

Or if you prefer to fix it by yourself then good for you.

Wink

_________________
The Answer Get it now.
Batam Web Network Most likely the content of this site is not for you...
Find all posts by sengsaraView user's profileSend private messageSend e-mailVisit poster's website
Chan1975
Nuke Soldier
Nuke Soldier


Joined: Feb 04, 2004
Posts: 12


PostPosted: Sun Feb 15, 2004 6:45 pm Reply with quoteBack to top

Table 'phpnuke.nuke_faqCategories' doesn't exist

Warning: Supplied argument is not a valid MySQL result resource in /home/httpd/vhosts/chanistheman.com/httpdocs/nuke/includes/sql_layer.php on line 288
Table 'phpnuke.nuke_faqCategories' doesn't exist
Find all posts by Chan1975View user's profileSend private message
sengsara
Support Staff
Support Staff


Joined: Sep 18, 2003
Posts: 289

Location: Batam, Indonesia (an hour boat ride from Singapore) ;)

PostPosted: Sun Feb 15, 2004 6:55 pm Reply with quoteBack to top

sengsara wrote:
This will help you pinpoint the exact problem.

Now you know that the problem is wrong table name! And there's a post above that you should read.
Thraxus wrote:
Thanks xgate32. That debug version of sql_layer.php did the trick.

To those of you who haven't replaced your default sql_layer.php with the one posted above, I recommend you do. It was simple finding the problem afterward.

The fix (at least on my site):
In both /admin/modules/adminfaq.php & /modules/FAQ/index.php
Find all instances of faqCategories and replace with faqcategories

One letter with the wrong case and all hell breaks loose. Razz

_________________
The Answer Get it now.
Batam Web Network Most likely the content of this site is not for you...
Find all posts by sengsaraView user's profileSend private messageSend e-mailVisit poster's website
Chan1975
Nuke Soldier
Nuke Soldier


Joined: Feb 04, 2004
Posts: 12


PostPosted: Sun Feb 15, 2004 6:56 pm Reply with quoteBack to top

why are there so many errors in php nuke?
Find all posts by Chan1975View user's profileSend private message
sengsara
Support Staff
Support Staff


Joined: Sep 18, 2003
Posts: 289

Location: Batam, Indonesia (an hour boat ride from Singapore) ;)

PostPosted: Sun Feb 15, 2004 7:00 pm Reply with quoteBack to top

Oh dear.

_________________
The Answer Get it now.
Batam Web Network Most likely the content of this site is not for you...
Find all posts by sengsaraView user's profileSend private messageSend e-mailVisit poster's website
Chan1975
Nuke Soldier
Nuke Soldier


Joined: Feb 04, 2004
Posts: 12


PostPosted: Sun Feb 15, 2004 7:01 pm Reply with quoteBack to top

I did that and still the same error.
Find all posts by Chan1975View user's profileSend private message
TrevorE
Lieutenant
Lieutenant


Joined: Dec 28, 2003
Posts: 292


PostPosted: Sun Feb 15, 2004 7:40 pm Reply with quoteBack to top

Also, change all instances of faqAnswer to faqanswer
Find all posts by TrevorEView user's profileSend private message
Redleg
Nuke Soldier
Nuke Soldier


Joined: Nov 21, 2003
Posts: 25


PostPosted: Mon Feb 16, 2004 8:13 am Reply with quoteBack to top

Ugh! I'm still having a bit of a problem. Using PhPNuke 6.9, I have:

1) renamed the tables to faqanswer and faqcategories;
2)replaced all instances of faqAnswer and faqCategories with lower case in my /admin/modules/adminfaq.php and /modules/faq/index.php
3) replaced my default sql_layer.php with the code above.

Now I am getting the following error:

You have an error in your SQL syntax near 'nine'' at line 1

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/virtual/site65/fst/var/www/html/includes/sql_layer.php on line 289
You have an error in your SQL syntax near 'nine'' at line 1


here is the code from lines 287 - 292:
Code:

    case "MySQL":
        $row = mysql_fetch_row($res);
        if (mysql_errno()) { echo mysql_error()."<br>"; }
        return $row;
    break;;


Do I need to reload my default sql_layer.php once I have fixed some problem or do I leave the code above as my new sql_layer.php?
Find all posts by RedlegView user's profileSend private message
Redleg
Nuke Soldier
Nuke Soldier


Joined: Nov 21, 2003
Posts: 25


PostPosted: Mon Feb 16, 2004 1:54 pm Reply with quoteBack to top

Found the answer, rather my service provider did.

http://www.nukecops.com/postp97267.html#97267
Find all posts by RedlegView user's profileSend private message
Display posts from previous:      
This forum is locked: you cannot post, reply to, or edit topics.  This topic is locked: you cannot edit posts or make replies.printer-friendly view
View previous topic Log in to check your private messages View next topic
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Powered by phpBB © 2001, 2005 phpBB Group

Ported by Nuke Cops © 2003 www.nukecops.com
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::
Powered by · TOGETHER TEAM srl ITALY http://www.togetherteam.it · DONDELEO E-COMMERCE http://www.DonDeLeo.com
Web site engine's code is Copyright © 2002 by PHP-Nuke. All Rights Reserved. PHP-Nuke is Free Software released under the GNU/GPL license.
Page Generation: 1.230 Seconds - 194 pages served in past 5 minutes. Nuke Cops Founded by Paul Laudanski (Zhen-Xjell)
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::