Hi :)

Somewhat newbie question...

I'm trying to include some open source classes into a project I am working
on. The classes build a set of relational select menus from the contents of
two tables. I have not trouble using the classes in a simple test page, but
am running into problems when I try to use them as part of a function. For
instance the following works just fine...

<?
session_start();
session_register("session");

include_once("config.php");
include_once ("functions.php");
include_once("head.php");
loginCheck(3);
global $config;

echo "a bunch of my own stuff";

// this is the class stuff I am trying to include
require("mysql_connection.php");
require("mysql_recordset.php");
require ("linked_select_class.php");
$conn = new mysql_conn("localhost","user","pass","database") ;
$conn->init() ;
$ls = new linked_select("conn","testselect","clients","Select
Client","id","company",1,"pieces","Select
Piece","id","title","client_id",0,1) ;
$ls->create_javascript();
$ls->create_base_select();
$ls->create_sub_select_multi();
// the end of the class stuff

echo "a bunch more of my own stuff";

include("foot.php");
?>

While this does not...

<?
session_start();
session_register("session");

include_once("config.php");
include_once ("functions.php");
include_once("head.php");
loginCheck(3);
global $config;


function whatever() {
    global $config;
    echo "a bunch of my own stuff";
    // this is the class stuff I am trying to include
    require("mysql_connection.php");
    require("mysql_recordset.php");
    require ("linked_select_class.php");
    $conn = new mysql_conn("localhost","user","pass","database") ;
    $conn->init() ;
    $ls = new linked_select("conn","testselect","clients","Select
Client","id","company",1,"pieces","Select
Piece","id","title","client_id",0,1) ;
    $ls->create_javascript();
    $ls->create_base_select();
    $ls->create_sub_select_multi();
    // the end of the class stuff
    echo "a bunch more of my own stuff";
}

$main_content = whatever();
echo "$main_content";

include("foot.php");
?>

It returns an error like 'Call to undefined function:  debug() in
/xxx/xxx/mysql_recordset.php on line 40'. When I check this line out, it is
' $GLOBALS[$this->connobj]->debug() ;'.

Now I know this function exists (it's in the required file
'mysql_connection.php'), and works from my simple test. Quickly commenting
out the line 40 allows the page to finish rendering, but the select menus
are empty, so my guess is the 'connobj' is not being passed along or the 3
required class files are not talking to each other in some way ;)

Doing some reading in the manual tells me it's a scope issue (I think). I
thought though that $GLOBALS was a super global but I guess I just don't get
the concept yet. I've tried declaring all sorts of things as global in my
function whatever() to no avail.

Is there something really basic that I am missing in understanding, or is
this a more complex thing?

TIA,
Verdon
Ps. Cc'ing to me when/if replying to list would be appreciated as I am on
digest mode :)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to