1

I have the following class to another class in my main class.

class Products 
{
 public function __get( $key ){
 return trim(functions::mssql_escape_string_rev($this->fields[ $key ]));
 }
}

This beings back error: Call to undefined method functions::mssql_escape_string_rev()

Is there something wrong with my syntax or can this not be done?

Below is code used to autoload classes, this works for everything else so I know there is nothign wrong with the code. It just doesnt seem to initiate within the class.

// autoloader function called when we try to instantiate a class but haven't included the file
function __autoload($resource_name){
 $resource_name = trim($resource_name);
 try { 
 $filepath = CLASS_PATH."/class.".$resource_name.".inc.php";
 if(@!include($filepath)){
 throw new Exception('');
 }
 } catch(Exception $e) {
 exit("Could not find the required file: ".$resource_name);
 }
}

*******EDIT***** Please ignore this, I made a stupid mistake and included the functions::mssql_escape_string_rev twice. Sorry for timewasting..

asked Dec 20, 2011 at 12:31
10
  • "functions" is your another class? Commented Dec 20, 2011 at 12:32
  • Does functions is a class you defined ? Commented Dec 20, 2011 at 12:37
  • yes, it is a class full of static functions. Commented Dec 20, 2011 at 12:37
  • I use an autoloader so I do not have to include each class. This works when I am not wihin another class. Commented Dec 20, 2011 at 12:38
  • 1
    Are you aware that there is a huge difference between object oriented programming and class oriented programming. Instead of creating a static class, you should just use simple function, wrapped in a namespace. Additionally: use PDO. Commented Dec 20, 2011 at 14:32

1 Answer 1

1

As the error says the problem is that functions::mssql_escape_string_rev() is not defined.

Since we can't see what you think is the definition we can not really help you.

For me it looks like the call should be Functions::mysql_escape_string_rev() with capital F and mysql.

Update

Calling static functions from another class works normally: http://codepad.org/wrfm5X7j

Maybe you are calling mysql_escape_string_rev before you included the functions class.

answered Dec 20, 2011 at 12:41

7 Comments

Why shouldn't he be using mssql? But I agree with the capital F.
Oh, he could. But since we don't know, I can only guess and mysql is more likely then mssql.
I am using mssql not mysql. Also my class functions is with a small f not capital. Therefore my method title and class title is correct PS. I'm a she ;0)
Do I need to add define functions within my class? I really am at a loss to see whats wrong here..
oh, sorry about that! How about posting the declaration of functions::mssql_escape_string_rev()?
|

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.