Breo Breo - 1 year ago 97
PHP Question

How to call functions in other PHP files?

I am trying to call a function from one file to another in PHP, however, I am getting the following error:

Fatal error: Call to undefined method SQLite3::print_model_query_form()

I have two files. The first -

contains the method
The second file
contains the following code:

$db = new SQLite3('D:\xampp\sim\htdocs\dis_sqlite_database\disSQL3.db');
print $db->print_model_query_form("query_models.php");

The function looks a little like this:

function print_model_query_form($action, $current_values = 0){
$db = new SQLite3('D:\xampp\sim\htdocs\dis_sqlite_database\disSQL3.db');

// set to previous values.
// get POST values.

// Code to print query form.

Thanks in advance for any help.

Answer Source

Since you only hit fatal error on 3rd line, $db should be instantiated successfully. So, the issue should be the print_model_query_form method.

Referring to PHP:SQLite3 - Manual

, there is no such built in method called print_model_query_form.

[Edit 1] Try to use require_once instead of include_once to make sure you have included dbfunctions.php successfully.

[Edit 2] Check If you are using PHP's built in SQLite3 class (check your php.ini for extension=php_sqlite3.dll or

If this is the case, check your dbfunctions.php for:-

  • class Something
  • new SQLite3
  • function print_model_query_form

If all the above exists then you should replace your 2nd line with, $db = new Something(..);

Note: It would be better if you can show dbfunctions.php instead or letting us make assumptions based on guessing.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download