-3

I'm facing a really weird problem on php 5.3.28

i have this code :

ob_start( );
session_start( );
include( "../common.php" );
check_user_login( );
$Pageination->Pagination( );
$p = $Pageination;

i use this code for all my website for pagination, but i dont know why some time i get this error

PHP Fatal error: Call to undefined function Pagination() in

and sometime this code work just fine with out error !

[UPDATED 1 ]

this code from my main/main.php

ob_start( );
session_start( );
include( "../common.php" );
check_user_login( );
$Var_120->Pagination( );
$p = $Var_120;
$page = setpage( );
$Var_336->AdminLoginlist( );
$al = $Var_336;

and its working

no this code from my main/edit-faq.php

ob_start( );
session_start( );
include( "../common.php" );
check_user_login( );
$Var_312->Pagination( );
$p = $Var_312;
$page = setpage( );
$Var_528->viewcategory( );

not working and error is right at

Fatal error: Call to a member function Pagination() on a non-object in /home/zmiintco/public_html/z/main/edit-faq.php on line 91

this is my common.php code

include( "lib/connect.php" );
include( "lib/function.php" );
include( "lib/pagination.php" );
include( "lib/validation.php" );
include( "lib/simpleimage.php" );
include( "language/".get_page_settings( "11" ).".php" );
scohe001
  • 15,110
  • 2
  • 31
  • 51
madman
  • 319
  • 2
  • 6
  • 19

2 Answers2

0

You probably have error reporting set to not display warnings. As a result you don't see that your include() statement fails. As a result your Paginator class is not available to your script and causes a fatal error when you try to instantiate it.

See How to get useful error messages in PHP? for details on how to set up error reporting properly.

This is most likely due to the fact that you use a relative path to that file which is incorrect when the script is not one directory beneath the directory containing it. Change the path to the include to be an absolute path to solve this problem.

For example:

include( "/full/path/to/includes/common.php" );
Community
  • 1
  • 1
John Conde
  • 217,595
  • 99
  • 455
  • 496
  • im perty sure i dont have any related path problem – madman Jun 25 '14 at 00:00
  • "Pretty sure" is not "100% sure". And it is the *only* explanation for why it sometimes works. It is generally a good practice to use full paths to avoid this issue anyway. – John Conde Jun 25 '14 at 00:01
  • both of them use same code one working another dont . – madman Jun 25 '14 at 00:30
  • That's a good indication that this is your problem. Have you tried putting **the full path in your PHP code**? That is how you will know for sure. It should be **the very next thing you do**. – John Conde Jun 25 '14 at 00:32
  • is it possible my shared host is source of all my problem ? – madman Jun 25 '14 at 00:33
  • It is very unlikely. There isn't raelly anything they can do to cause this. – John Conde Jun 25 '14 at 00:35
0

Firstly, set your error reporting on at the top of your script:

error_reporting(E_ALL);
ini_set('display_errors', 1);

Now you will most likely get the error (as you stated) that:

PHP Fatal error: Call to undefined function Pagination() in

And that would be because your variable $Pageination wasn't instantiated. Simply instantiate it and then call its member functions.

ob_start( );
session_start( );
include( "../common.php" );
check_user_login( );

$Pageination = new Pagination();
$Pageination->Pagination( );
$p = $Pageination;

Pressuming that it is a class that is present somewhere within your common.php include?


Could you possibly show the code within your common.php ?

Darren
  • 13,050
  • 4
  • 41
  • 79