hi there:twisted:
i'm verry new here but i hope that there is sombody here that can help me with the following

i have a fusker script called fusker.ne build in in a verry old xoops engine
i wil use this script again but there is a verry hard to understand sql error
i think the problem is php 5 becouse the script is from 1996
and in that time there was php 4 normal.

this error apears in admin so i cant do annything annymore

so now the code: error

Error Number: 2 [Warning]
Error Message: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
In File: /home/admin/domains/fusker-development.info/public_html/v2/class/database/ez_sql.php
On Line: 477

the page code of that area is:

function fetch_row($resource) {
		$result = mysql_fetch_row($resource);
		return $result;
	}

	function fetch_array($resource) {

		$result = mysql_fetch_array($resource);
		return $result;
	}

thanks i hope there is someone that have a solution for me to fix

First ensure that , $resource is your query or query result.

means $resource should be come after this statement.
$resource=mysql_query($Your_Query_String);

ok so can you give me a example of a line from so can more understand how to do?
thanks

What ankit means,

function fetch_row($resource) {
		$result = mysql_fetch_row($resource);
		return $result;
	}

	function fetch_array($resource) {

		$result = mysql_fetch_array($resource);
		return $result;
	}

$q="select * from user";
$res = mysql_query($q);
$output = fetch_row($res );

Firstly check your sql query.Is it right or not?
and return of mysql_query should be passed to your function.

$resource=mysql_query("select * from user");
function fetch_row($resource)
 {
       $result = mysql_fetch_row($resource);
        return $result;
}
function fetch_array($resource)
 { 
        $result = mysql_fetch_array($resource);
        return $result; 
}

I am giving the sample code for mysql_fetch_row() and mysql_fetch_array(). This will be helpful.

// For mysql_fetch_array()

 $Query00 = "SELECT ReportingTo from Resources";
    $Result00 = mysql_query($Query00);
   while($row00 = mysql_fetch_array($Result00))
    {
            //You can display all data Here
    }

// For mysql_fetch_row()

$Query="select count(PRODUCT_ID) from fg_item_no_list where `FG_ITEM_NUMBER` like '$fg_item1%'"; 

  $Result = mysql_query($Query);
  $row = mysql_fetch_row($Result);   

//You can display data through row[0]....

ok but when i do that chance i get this!

Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in /home/admin/domains/fusker-development.info/public_html/v2/class/database/ez_sql.php on line 470

line 470 is firstline what you offerd me

so do miss somthing?
thanks for helping me by the way ankit!

sorry but iám a verry newbie in hardcoded phpmysql

ok i have added the ful page so you can see more of it:

<?php

// CODE FOR THIS FILE COMES FROM THREE PLACES,
// LISTED BELOW ROUGHLY IN THE ORDER IN WHICH THEY APPEAR:

// $Id: database.php,v 1.3 2003/01/10 19:29:51 half-dead Exp $
// Original Author: Kazumi Ono
// Author Website : http://www.mywebaddons.com/ , http://www.myweb.ne.jp
// Licence Type   : GPL
// ------------------------------------------------------------------------- //


// ==================================================================
//  Author: Justin Vincent (justin@visunet.ie)
//  Web:    http://php.justinvincent.com
//  Name:   ezSQL
//  Desc:   Class to make it very easy to deal with mySQL database connections.
//
// !! IMPORTANT !!
//
//  Please send me a mail telling me what you think of ezSQL
//  and what your using it for!! Cheers. [ justin@visunet.ie ]
//
// ==================================================================


// $Id: mysql.php,v 1.9 2003/01/10 19:20:18 half-dead Exp $
// Original Author: Half-Dead
// Author Website : http://www.e-xoops.com
// Licence Type   : Proprietary
// ------------------------------------------------------------------------- //


// FROM database.php

class AbsDatabase {
	var $prefix;
	var $debug;

	function setPrefix($value='') {
		$this->prefix = $value;
	}

	function prefix($tablename='') {

	if ($tablename == '') {
		return $this->prefix;
		} else {
			if ($this->prefix == '') {
				return $tablename;
				} else {
					return $this->prefix ."_". $tablename;
				}
		}
	}

	function setDebug($level=1) {

		if (intval($level) & 1) {
			error_reporting(2039);
		} else {
			error_reporting(0);
		}

	$this->debug = intval($level);
	}
}

// FROM ez_sql.php
define('EZSQL_VERSION',"1.25");
define('OBJECT',"OBJECT",true);
define('ARRAY_A',"ARRAY_A",true);
define('ARRAY_N',"ARRAY_N",true);

class Database extends AbsDatabase {

    var $debug_called;
    var $vardump_called;
    var $show_errors = true;
    var $num_queries = 0;

    function Database($dbuser, $dbpassword, $dbname, $dbhost)
    {
		global $xoopsConfig;

		// Edited to include possibility of persistant connection
		if ($xoopsConfig['db_pconnect']) {
			$this->dbh = @mysql_pconnect($dbhost,$dbuser,$dbpassword);
		} else {
        	$this->dbh = @mysql_connect($dbhost,$dbuser,$dbpassword);
        }

        if ( ! $this->dbh ) {
            $this->print_error("<ol><b>Error establishing a database connection!</b><li>Are you sure you have the correct user/password?<li>Are you sure that you have typed the correct hostname?<li>Are you sure that the database server is running?</ol>");
        }

        $this->select($dbname);

    }

    function select($db) {
        if ( !@mysql_select_db($db,$this->dbh))
        {
            $this->print_error("<ol><b>Error selecting database <u>$db</u>!</b><li>Are you sure it exists?<li>Are you sure there is a valid database connection?</ol>");
        }
    }


    function escape($str) {
        return mysql_escape_string(stripslashes($str));
    }

    function print_error($str = "") {

        global $EZSQL_ERROR;

        if ( !$str ) $str = mysql_error();

        $EZSQL_ERROR[] = array
                        (
                            "query" => $this->last_query,
                            "error_str"  => $str
                        );

        if ( $this->show_errors ) {
            // If there is an error then take note of it
            print "<blockquote><font face=arial size=2 color=ff0000>";
            print "<b>SQL/DB Error --</b> ";
            print "[<font color=000077>$str</font>]";
            print "</font></blockquote>";
        } else {
            return false;
        }

    }

    function show_errors() {
        $this->show_errors = true;
    }

    function hide_errors() {
        $this->show_errors = false;
    }

    function flush() {
        $this->last_result = null;
        $this->col_info = null;
        $this->last_query = null;
    }


    function ez_query($query) {

		$return_val = 0;
        $this->flush();
        $this->func_call = "\$db->ez_query(\"$query\")";
        $this->last_query = $query;

        $this->result = @mysql_query($query,$this->dbh);
        $this->num_queries++;

        // If there is an error then take note of it..
		if ( mysql_error() )
		{
			$this->print_error();
			return false;
		}

        // Query was an insert, delete, update, replace
			if ( preg_match("/^\\s*(insert|delete|update|replace) /i",$query) ) {
				$this->rows_affected = mysql_affected_rows();

				// Take note of the insert_id
				if ( preg_match("/^\\s*(insert|replace) /i",$query) )
				{
					$this->insert_id = mysql_insert_id($this->dbh);
				}

				// Return number fo rows affected
				$return_val = $this->rows_affected;


			} else {

				// Query was an select
				// Take note of column info
				$i=0;
				while ($i < @mysql_num_fields($this->result)) {
					$this->col_info[$i] = @mysql_fetch_field($this->result);
					$i++;
				}

				// Store Query Results
				$num_rows=0;
				while ( $row = @mysql_fetch_object($this->result) ) {
					// Store relults as an objects within main array
					$this->last_result[$num_rows] = $row;
					$num_rows++;
				}

				@mysql_free_result($this->result);

				// Log number of rows the query returned
				$this->num_rows = $num_rows;

				// Return number of rows selected
				$return_val = $this->num_rows;
			}
        // If debug ALL queries
			$this->trace || $this->debug_all ? $this->debug() : null ;

			return $return_val;

		}

    function get_var($query=null,$x=0,$y=0)  {
        $this->func_call = "\$db->get_var(\"$query\",$x,$y)";

        if ( $query )  {
            $this->ez_query($query);
        }

        if ( $this->last_result[$y] )  {
            $values = array_values(get_object_vars($this->last_result[$y]));
        }

        return (isset($values[$x]) && $values[$x]!=='')?$values[$x]:null;
    }



    function get_row($query=null,$output=OBJECT,$y=0)  {

        $this->func_call = "\$db->get_row(\"$query\",$output,$y)";

        if ( $query ) {
            $this->ez_query($query);
        }

        if ( $output == OBJECT ) {
            return $this->last_result[$y]?$this->last_result[$y]:null;
        } elseif ( $output == ARRAY_A ) {
            return $this->last_result[$y]?get_object_vars($this->last_result[$y]):null;
        } elseif ( $output == ARRAY_N ) {
            return $this->last_result[$y]?array_values(get_object_vars($this->last_result[$y])):null;
        } else {
            $this->print_error(" \$db->get_row(string query, output type, int offset) -- Output type must be one of: OBJECT, ARRAY_A, ARRAY_N");
        }

    }


    function get_col($query=null,$x=0) {

        if ( $query ) {
            $this->ez_query($query);
        }

        for ( $i=0; $i < count($this->last_result); $i++ ) {
            $new_array[$i] = $this->get_var(null,$x,$i);
        }

        return $new_array;
    }

    function get_results($query=null, $output = OBJECT) {

        $this->func_call = "\$db->get_results(\"$query\", $output)";

        if ( $query ) {
            $this->ez_query($query);
        }

        if ( $output == OBJECT )
        {
            return $this->last_result;
        }
        elseif ( $output == ARRAY_A || $output == ARRAY_N )
        {
            if ( $this->last_result )
            {
                $i=0;
                foreach( $this->last_result as $row )
                {

                    $new_array[$i] = get_object_vars($row);

                    if ( $output == ARRAY_N )
                    {
                        $new_array[$i] = array_values($new_array[$i]);
                    }

                    $i++;
                }

                return $new_array;
            }
            else
            {
                return null;
            }
        }
    }

    function get_col_info($info_type="name",$col_offset=-1)
    {

        if ( $this->col_info ) {
            if ( $col_offset == -1 ) {
                $i=0;
                foreach($this->col_info as $col )  {
                    $new_array[$i] = $col->{$info_type};
                    $i++;
                }
                return $new_array;
            } else {
                return $this->col_info[$col_offset]->{$info_type};
            }

        }

    }

    function vardump($mixed='') {

        echo "<p><table><tr><td bgcolor=ffffff><blockquote><font color=000090>";
        echo "<pre><font face=arial>";

        if ( ! $this->vardump_called )
        {
            echo "<font color=800080><b>ezSQL</b> (v".EZSQL_VERSION.") <b>Variable Dump..</b></font>\n\n";
        }

        $var_type = gettype ($mixed);
        print_r(($mixed?$mixed:"<font color=red>No Value / False</font>"));
        echo "\n\n<b>Type:</b> " . ucfirst($var_type) . "\n";
        echo "<b>Last Query</b> [$this->num_queries]<b>:</b> ".($this->last_query?$this->last_query:"NULL")."\n";
        echo "<b>Last Function Call:</b> " . ($this->func_call?$this->func_call:"None")."\n";
        echo "<b>Last Rows Returned:</b> ".count($this->last_result)."\n";
        echo "</font></pre></font></blockquote></td></tr></table>".$this->donation();
        echo "\n<hr size=1 noshade color=dddddd>";

        $this->vardump_called = true;

    }

    function dumpvar($mixed) {
        $this->vardump($mixed);
    }

    function debug() {

        echo "<blockquote>";

        if ( ! $this->debug_called ) {
            echo "<font color=800080 face=arial size=2><b>ezSQL</b> (v".EZSQL_VERSION.") <b>Debug..</b></font><p>\n";
        }
        echo "<font face=arial size=2 color=000099><b>Query</b> [$this->num_queries] <b>--</b> ";
        echo "[<font color=000000><b>$this->last_query</b></font>]</font><p>";

            echo "<font face=arial size=2 color=000099><b>Query Result..</b></font>";
            echo "<blockquote>";

        if ( $this->col_info ) {

            echo "<table cellpadding=5 cellspacing=1 bgcolor=555555>";
            echo "<tr bgcolor=eeeeee><td nowrap valign=bottom><font color=555599 face=arial size=2><b>(row)</b></font></td>";


            for ( $i=0; $i < count($this->col_info); $i++ ) {
                echo "<td nowrap align=left valign=top><font size=1 color=555599 face=arial>{$this->col_info[$i]->type} {$this->col_info[$i]->max_length}</font><br><span style='font-family: arial; font-size: 10pt; font-weight: bold;'>{$this->col_info[$i]->name}</span></td>";
            }
            echo "</tr>";
	        if ( $this->last_result ) {

	            $i=0;
	            foreach ( $this->get_results(null,ARRAY_N) as $one_row ) {
	                $i++;
	                echo "<tr bgcolor=ffffff><td bgcolor=eeeeee nowrap align=middle><font size=2 color=555599 face=arial>$i</font></td>";
	                foreach ( $one_row as $item ) {
	                    echo "<td nowrap><font face=arial size=2>$item</font></td>";
	                }
	                echo "</tr>";
	            }

	        } else {
	            echo "<tr bgcolor=ffffff><td colspan=".(count($this->col_info)+1)."><font face=arial size=2>No Results</font></td></tr>";
	        }

	        echo "</table>";

        } else {
            echo "<font face=arial size=2>No Results</font>";
        }
        echo "</blockquote></blockquote>".$this->donation()."<hr noshade color=dddddd size=1>";
        $this->debug_called = true;
    }

    function donation() {
        return "<font size=1 face=arial color=000000>If ezSQL has helped <a href=\"https://www.paypal.com/xclick/business=justin%40justinvincent.com&item_name=ezSQL&no_note=1&tax=0\" style=\"color: 0000CC;\">make a donation!?</a> &nbsp;&nbsp;[ go on! you know you want to! ]</font>";
    }


// BEGIN mysql.php
	function close() {
		return mysql_close($this->dbh);
	}


	function affected_rows() {

		$result = mysql_affected_rows($this->dbh);
		return $result;
	}

	function query($sql, $limit=0, $start=0) {

		if ( ($this->debug & 8) || ($this->debug & 16) ) {
			$this->query_log[] = $sql;
			} else {
				$this->query_log[] = 0;
			}

		if ( !empty($limit) ) {
			if (empty($start)) {
				$start = 0;
			}
			$sql = $sql. " LIMIT ".intval($start).",".intval($limit)."";
		}

		if ($this->debug & 16) {
			$output = count($this->query_log).": ".$sql;
			if ( function_exists('xdebug_call_function') ) {
				$output = "<b>".xdebug_call_function()."()</b><br />".$output;
			}
			$this->bg = ($this->bg == 'bg3') ? $this->bg = 'bg1' : $this->bg = 'bg3';
			echo "<div align='left' style='border-top:1px dashed #003030; padding: 3px;' class='".$this->bg."'>".$output."</div>";
		}

		$result = mysql_query($sql, $this->dbh);
		return $result;
	}

	function genId($sequence) {
		return 0;
	}

	function num_fields($resource) {
		$result = mysql_num_fields($resource);
		return $result;
	}

	function field_name($resource, $index) {
		$result = mysql_field_name($resource, $index);
		return $result;
	}


	function fetch_object($resource) {
		$result = mysql_fetch_object($resource);
		return $result;
	}

	function insert_id() {
		$result = mysql_insert_id($this->dbh);
		return $result;
	}


$resource=mysql_query("select * from user");
function fetch_row($resource)
{
$result = mysql_fetch_row($resource);
return $result;
}
function fetch_array($resource)
{ 
$result = mysql_fetch_array($resource);
return $result;	
}

	function error() {
		if ($this->debug & 1) {
			$result = mysql_errno($this->dbh) . ": " . mysql_error($this->dbh);
			return $result;
		}
	}

	function field_type($resource, $offset) {
		$result = mysql_field_type($resource, $offset);
		return $result;
	}

	function num_rows($resource) {
		$result = mysql_num_rows($resource);
		return $result;
	}

}




?>

hi Cobrax,

Try this one .... Actually , i have no full info about ur program. If it will not work , then you can explain in detail. Like exactly what you want to do with this function and what is your query.......

$resource = mysql_query("select name,age from user");
function fetch_row($resource)
{
$result = mysql_fetch_row($resource);
return array ({$result}, {$result});
}

commented: good guy +1

can u give details of user table?

user table:

--
-- Database: `admin_fuskerne`
--

-- --------------------------------------------------------

--
-- Tabelstructuur voor tabel `fusker_users`
--

CREATE TABLE IF NOT EXISTS `fusker_users` (
  `uid` mediumint(8) unsigned NOT NULL auto_increment,
  `name` varchar(30) NOT NULL default '',
  `uname` varchar(30) NOT NULL default '',
  `email` varchar(60) NOT NULL default '',
  `url` varchar(255) NOT NULL default '',
  `user_avatar` varchar(255) NOT NULL default '',
  `user_regdate` int(10) unsigned NOT NULL default '0',
  `user_icq` varchar(15) NOT NULL default '',
  `user_from` varchar(60) NOT NULL default '',
  `user_sig` varchar(255) NOT NULL default '',
  `user_viewemail` tinyint(1) unsigned NOT NULL default '0',
  `actkey` varchar(8) NOT NULL default '',
  `user_aim` varchar(60) NOT NULL default '',
  `user_yim` varchar(60) NOT NULL default '',
  `user_msnm` varchar(60) NOT NULL default '',
  `pass` varchar(32) NOT NULL default '',
  `posts` smallint(5) unsigned NOT NULL default '0',
  `attachsig` tinyint(1) unsigned NOT NULL default '0',
  `rank` int(5) NOT NULL default '0',
  `level` int(5) NOT NULL default '1',
  `theme` varchar(30) NOT NULL default '',
  `timezone_offset` tinyint(2) NOT NULL default '0',
  `last_login` int(10) unsigned NOT NULL default '0',
  `umode` enum('flat','thread','0') NOT NULL default 'flat',
  `uorder` tinyint(1) unsigned NOT NULL default '0',
  `user_occ` varchar(60) NOT NULL default '',
  `bio` varchar(255) NOT NULL default '',
  `user_intrest` varchar(255) NOT NULL default '',
  `user_mailok` tinyint(1) unsigned NOT NULL default '1',
  PRIMARY KEY  (`uid`),
  UNIQUE KEY `email` (`email`),
  UNIQUE KEY `uname` (`uname`),
  KEY `idx` (`uname`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

ps i have send you a pm

thanks gabor

sorry had double post

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.