Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6046517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:14:55+00:00 2026-05-23T07:14:55+00:00

When I execute this code I get an error saying PHP Fatal error: Call

  • 0

When I execute this code I get an error saying “PHP Fatal error: Call to a member function Execute() on a non-object”. The line that causes this error is line 96: $ok = $DB->Execute($sql, $aWhereParams); I have tried to solve this, but i wasn’t succesfull. Probably the code doesn’t return an object? How can I catch this error or is there something wrong with my code? Please help. Thanks!

SykWitIt

<?php

include_once 'config.php';
include_once('/apps/geoservices/apps/geoservices2.4/config/settings.php');
include_once('/apps/geoservices/apps/geoservices2.4/htdocs/utils.php');

if ($argc < 2)
{
    echo "Usage: php daemon.php <samba share>\n";
    exit(1);
}
elseif (is_dir($argv[1]))
{
    global $base;
    $base = $argv[1];

    // Dir_walk recursively walks to the root directory and all the subdirectory's
    dir_walk('handleFile', $argv[1], array('xml'), true, '', $argv[1]);
}
else
{
    echo "The parameter given for the samba share is not a directory.\n";
    exit(1);
}

function handleFile($base, $dir, $filehandle)
{
    //Get the application name
    $application_name = substr($dir, 0, -1);
    $application_name = strtolower(str_replace('\\', '_', $application_name)."_".substr($filehandle, 0, strrpos($filehandle, '.')));


    // Set the parameters needed to insert the WMC into the database
    $aWhereParams = array();

    $file = $base.$dir.$filehandle;
    $aWhereParams['appname'] = strtolower($application_name);
    $aWhereParams['password'] = generatePassword();
    $aWhereParams['wmctitle'] = null;
    $aWhereParams['folder'] = null;
    $aWhereParams['startwmc'] = 'Y';
    $aWhereParams['userid'] = null;

    $DB = createDatabaseConnection($dbconnect, $dbuser, $dbpasswd);

    if ($aWhereParams['folder'] !== null) 
    {
        // check if folder is already created
        $sql = "SELECT FOLDERID FROM WMCFOLDERS WHERE FOLDERTITLE = :folder AND APPLICATION=:appname";
        $ok = $DB->Execute($sql, $aWhereParams);
        if ($ok) 
        {
            $myArray = $ok->GetArray();
            if (empty($myArray)) 
            {
                // insert the folder into WMCFOLDERS
                createWMCDirectory($DB, $aWhereParams);
            } 
            else 
            {
                foreach ($myArray as $row) 
                {
                    $aWhereParams['folderid'] = $row['FOLDERID'];
                }
            }
        }
    } 
    else 
    {
        $aWhereParams['folderid'] = null;
    }

    $folderIdValue;
    if ($aWhereParams['folderid'] === null) 
    {
        $folderIdValue = 'IS NULL';
    } 
    else 
    {
        $folderIdValue = '='.$aWhereParams['folderid'];
    }

    $titleValue;
    if ($aWhereParams['wmctitle'] === null) 
    {
        $titleValue = 'IS NULL';
    } 
    else 
    {
        $titleValue = '='.$DB->qstr($aWhereParams['wmctitle'], get_magic_quotes_gpc());
    }

    // check if there is an existing entry, if so update it
    $sql = "SELECT APPLICATION FROM WMC WHERE STARTWMC=:startwmc AND APPLICATION=:appname AND FOLDERID ".$folderIdValue." AND TITLE ".$titleValue;
    $ok = $DB->Execute($sql, $aWhereParams);
    if ($ok) 
    {
        $myArray = $ok->GetArray();
        if (empty($myArray)) 
        {   
            // we need to insert a new entry
            $sql = "insert into WMC (USERID, APPLICATION, FOLDERID, TITLE, STARTWMC, WMC) values (null, :appname, :folderid, :wmctitle, :startwmc, null)";

            // Combine WMC name with the password for the new entry
            $aWhereParams['appname'] .= $aWhereParams['password'];

            $ok = $DB->Execute($sql, $aWhereParams);
            if (!$ok) 
            {
                handleDBError($DB);
            }

            insertCLOB($DB, $file, $aWhereParams['appname'], $aWhereParams['folderid'] , $aWhereParams['wmctitle']);

            foreach ($GLOBALS['emailadresses'] as $dienst => $emailaddress)
            {
                if ($dienst == $aWhereParams['appname'])
                {
                    // Set the email properties
                    $to = $emailaddress;
                    $subject = "Nieuwe WMC toegevoegd";
                    $message = "Er is een nieuwe WMC toegevoegd. Je kunt deze bekijken door naar het adres ".getURL()." te gaan en in te loggen met \n";
                    $message .= "gebruikersnaam: ".$aWhereParams['appname'];
                    $message .= "wachtwoord: ".$aWhereParams['password'];

                    $from = "test@blabla.com";
                    $headers = "From:".$from;

                    // Combine all property's and send the email
                    mail($to, $subject, $message, $headers);
                }
            }
        } 
        else 
        {
            insertCLOB($DB, $file, $aWhereParams['appname'], $aWhereParams['folderid'] , $aWhereParams['wmctitle']);

            foreach ($GLOBALS['emailadresses'] as $dienst => $emailaddress)
            {
                if ($dienst == $aWhereParams['appname'])
                {
                    // Set the email properties
                    $to = $emailaddress;
                    $subject = "Nieuwe WMC toegevoegd";
                    $message = "Er is een nieuwe WMC toegevoegd. Je kunt deze bekijken door naar het adres ".getURL()." te gaan.";

                    $from = "test@blabla.com";
                    $headers = "From:".$from;

                    // Combine all property's and send the email
                    mail($to, $subject, $message, $headers);
                }
            }
        }
    } 
    else 
    {
        handleDBError($DB);
    }

    echo "WMC '".$aWhereParams['wmctitle']."' loaded OK in folder '".$aWhereParams['folder']."'\n";
    echo "    for ".$aWhereParams['appname'].", $dbuser@$dbconnect\n";
}

// Generate a random password
function generatePassword()
{
    $length = 8;

    $password = "";
    $possible = "2346789bcdfghjkmnpqrtvwxyzBCDFGHJKLMNPQRTVWXYZ";

    $maxlength = strlen($possible);

    if ($length > $maxlength)
        $length = $maxlength;

    $i = 0; 
    while ($i < $length) 
    { 
      $char = substr($possible, mt_rand(0, $maxlength-1), 1);

      if (!strstr($password, $char)) 
      { 
        $password .= $char;
        $i++;
      }
    }

    return $password;
}

function getURL()
{
    //This will be URL
    return gethostname()."/apps/geoservices/";
}

function dir_walk($callback, $dir, $types = null, $recursive = false, $baseDir = '', $base)
{
    if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false)
        {
            if ($file === '.' || $file === '..')
            {
                continue;
            }
            if (is_file($dir . $file))
            {
                if (is_array($types))
                {
                    if (!in_array(strtolower(pathinfo($dir . $file, PATHINFO_EXTENSION)), $types, true))
                    {
                        continue;
                    }
                }
                $callback($base, $baseDir, $file);
            }
            elseif($recursive && is_dir($dir . $file))
            {
                dir_walk($callback, $dir . $file . DIRECTORY_SEPARATOR, $types, $recursive, $baseDir . $file . DIRECTORY_SEPARATOR, $base);
            }
        }
        closedir($dh);
    }
}
?>

This the function that creates an Oracle database connection given a connect string, user and pwd

function createDatabaseConnection($dbconnect, $dbuser, $dbpasswd)
{
  // we need adodb
  require_once('/usr/share/php/adodb/adodb.inc.php');

  // make sure that the OCI extension is loaded
  $szOCIModule = "php_oci8";
  if (!extension_loaded("oci8"))
      dl($szOCIModule . "." . PHP_SHLIB_SUFFIX);

   $DB = NewADOConnection('oci8');
   $DB->PConnect($dbconnect, $dbuser, $dbpasswd);
   if (!$DB) return false;
   if (!$DB->IsConnected()) return false;
   return $DB;
}

My other script works fine, the same DBConnection. The main difference is that in the script(with the error) i use function handleFile with some extra params. The code is here:

<?php

include_once(dirname(__FILE__).'/../config/settings.php');
include_once(dirname(__FILE__).'/../htdocs/utils.php');

if ($argc < 3) {
  echo "Usage: insertwmc.php <application> <wmc file> [title] [folder]\n";
  echo "\n";
  echo "Inserts the wmc file as a CLOB into the userprofile database for a specific application\n";
  echo "\n";
  echo "The wmc file should be an absolute path.\n";
  echo "\n";
  echo "If no title is specified, the WMC will become the default WMC for the application\n";
  echo "\n";
  exit(1);
}

$aWhereParams = array();

$file=$argv[2];
$aWhereParams['appname'] = strtolower($argv[1]);
$aWhereParams['wmctitle'] = null;
$aWhereParams['folder'] = null;
$aWhereParams['startwmc'] = 'Y';
if (isset($argv[3])) {
  $aWhereParams['wmctitle'] = $argv[3];
  $aWhereParams['startwmc'] = 'N';
}
if (isset($argv[4])) {
  $aWhereParams['folder'] = $argv[4];
}
$aWhereParams['userid'] = null;

$DB = createDatabaseConnection($dbconnect, $dbuser, $dbpasswd);

if ($aWhereParams['folder'] !== null) {
  // check if folder is already created
  $sql = "SELECT FOLDERID FROM WMCFOLDERS WHERE FOLDERTITLE = :folder AND APPLICATION=:appname";
  $ok = $DB->Execute($sql, $aWhereParams);
  if ($ok) {
    $myArray = $ok->GetArray();
    if (empty($myArray)) {
      // insert the folder into WMCFOLDERS
      createWMCDirectory($DB, $aWhereParams);
    } else {
      foreach ($myArray as $row) {
        $aWhereParams['folderid'] = $row['FOLDERID'];
      }
    }
  }
} else {
  $aWhereParams['folderid'] = null;
}

$folderIdValue;
if ($aWhereParams['folderid'] === null) {
  $folderIdValue = 'IS NULL';
} else {
  $folderIdValue = '='.$aWhereParams['folderid'];
}

$titleValue;
if ($aWhereParams['wmctitle'] === null) {
  $titleValue = 'IS NULL';
} else {
  $titleValue = '='.$DB->qstr($aWhereParams['wmctitle'], get_magic_quotes_gpc());
}

// check if there is an existing entry, if so update it
$sql = "SELECT APPLICATION FROM WMC WHERE STARTWMC=:startwmc AND APPLICATION=:appname AND FOLDERID ".$folderIdValue." AND TITLE ".$titleValue; 
$ok = $DB->Execute($sql, $aWhereParams);
if ($ok) {
  $myArray = $ok->GetArray();
  if (empty($myArray)) {
    // we need to insert a new entry
    $sql = "insert into WMC (USERID, APPLICATION, FOLDERID, TITLE, STARTWMC, WMC) values (null, :appname, :folderid, :wmctitle, :startwmc, null)";
    $ok = $DB->Execute($sql, $aWhereParams);
    if (!$ok) {
      handleDBError($DB);
    }
    insertCLOB($DB, $file, $aWhereParams['appname'], $aWhereParams['folderid'] , $aWhereParams['wmctitle']);
  } else {
    insertCLOB($DB, $file, $aWhereParams['appname'], $aWhereParams['folderid'] , $aWhereParams['wmctitle']);
  }
} else {
  handleDBError($DB);
}

echo "WMC '".$aWhereParams['wmctitle']."' loaded OK in folder '".$aWhereParams['folder']."'\n";
echo "    for ".$aWhereParams['appname'].", $dbuser@$dbconnect\n";

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:14:56+00:00Added an answer on May 23, 2026 at 7:14 am

    As seen from the function, it’s most likely returning false.

    What happens if you do var_dump($DB) right after the line $DB = createDatabaseConnection(...);

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Considering this code, can I be absolutely sure that the finally block always executes,
I am getting this error on a remote server, but the same code executes
I'm having a little problem with the following: When I execute this line: echo
I hit this error while my web application was trying to execute a SELECT
Well basically I have this script that takes a long time to execute and
This code is executed by many way. When it's executed by the form button
I am trying to execute this SQL query prior to restoring a .BAK file
I am trying to execute this SQL command: SELECT page.page_namespace, pagelinks.pl_namespace, COUNT(*) FROM page,
I need a real DBA's opinion. Postgres 8.3 takes 200 ms to execute this
What is this Execute Around idiom (or similar) I've been hearing about? Why might

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.