Undefined function call when required_once is in a function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dayoung
Forum Newbie
Posts: 2
Joined: Mon Jul 21, 2008 5:58 pm

Undefined function call when required_once is in a function

Post by dayoung »

Code: Select all

<?php
require_once('core.php');
class Mantis {
  
  function mantis_login($f_username,$f_password){
 
    if ( BASIC_AUTH == config_get( 'login_method' ) ) {
        $f_username = $_SERVER['REMOTE_USER'];
        $f_password = $_SERVER['PHP_AUTH_PW'];
    }
...
That works just fine but if I do this

Code: Select all

<?php
 
class Mantis {
  
  function mantis_login($f_username,$f_password){
    require_once('core.php');
    if ( BASIC_AUTH == config_get( 'login_method' ) ) {
        $f_username = $_SERVER['REMOTE_USER'];
        $f_password = $_SERVER['PHP_AUTH_PW'];
    }
...
I receive this error
Warning: 100 in /opt/lampp/htdocs/mantis/core/config_api.php on line 158

Warning: implode() [function.implode]: Bad arguments. in /opt/lampp/htdocs/mantis/core/config_api.php on line 330

Warning: 100 in /opt/lampp/htdocs/mantis/core/config_api.php on line 158

Warning: 100 in /opt/lampp/htdocs/mantis/core/config_api.php on line 158

Warning: 100 in /opt/lampp/htdocs/mantis/core/config_api.php on line 158

Fatal error: Call to undefined function db_is_connected() in /opt/lampp/htdocs/mantis/core/authentication_api.php on line 587
I've searched but I can't seem to get this to work or why it happens
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Undefined function call when required_once is in a function

Post by Christopher »

What is the code on the lines given in the warnings?
(#10850)
dayoung
Forum Newbie
Posts: 2
Joined: Mon Jul 21, 2008 5:58 pm

Re: Undefined function call when required_once is in a function

Post by dayoung »

Code: Select all

trigger_error( ERROR_CONFIG_OPT_NOT_FOUND, WARNING );
but if you want to see the whole code you can download it here.
http://sourceforge.net/project/showfile ... _id=166159

I'm trying to have another php page log into Mantis(Bug Tracking System)

But if I declare the require_once outside the class it works just fine but if it is declared inside a function that is the resulting error.
Post Reply