WeeniehuahuaXD
WeeniehuahuaXD

Reputation: 852

PHP - Fatal error class not found

I have the below contents in one of my files

<?php
require_once(DIR_INCLUDE .'/jsonwrapper/jsonwrapper.php');
require_once(DIR_INCLUDE .'/template.class.php');
require_once(DIR_INCLUDE .'/string.func.php');
require_once(DIR_INCLUDE .'/filesystem.func.php');
require_once(DIR_INCLUDE .'/database.php');
require_once(DIR_INCLUDE .'/login.class.php');
require_once(DIR_INCLUDE .'/user.class.php');
require_once(DIR_INCLUDE .'/querystring.class.php');
require_once(DIR_INCLUDE .'/resource.class.php');
require_once(DIR_INCLUDE .'/cache_thumbnail.class.php');
require_once(DIR_INCLUDE .'/hook.class.php');
require_once(DIR_INCLUDE .'/controller.class.php');
require_once(DIR_MODULES .'/pages/page.class.php');
require_once(DIR_MODULES .'/settings/settings.class.php');

/* Database Connect */
// Moved to config.php
// db_connect(DB_HOST,DB_USER,DB_PASSWORD,DB_NAME);

/* Handle Login Posting */
$login = new login();

if($login->is_login()){
  $login_user = new user($login->info['user_id']);

}
$common['querystring'] = new querystring($_GET);

Currently I'm seeing nothing but bare text on my web page and my apache log contains the following

[Mon Oct 19 20:08:58.683738 2015] [:error] [pid 9552] [client 107.137.15.190:58709] PHP Fatal error: Class 'querystring' not found in /var/www/html/inc/common.php on line 28

This is the contents of the query file.

<?
class querystring{
  var $myQueryString;
  var $original;

  function querystring($getvar){

    unset($getvar['path']);

    $this->myQueryString = $getvar;
    $this->original = $getvar;
  }

  function remove($except){
    if($except =="")return;

    $str_except = "";
    if(is_array($except)){
      foreach($except as $x){
        $str_except .= "[$x]";
      }
    }else{
      if($except!=""){
        $str_except = "[$except]";
      }
    }

    $str_ret = "";
    unset($new_qs);
    foreach($this->myQueryString as $key => $value){
      if(strpos(' '. $str_except, '['. $key .']')==0){
        $new_qs[$key] = $value;
      }
    }
    $this->myQueryString = $new_qs;
  }

  function add($key, $value){
    $this->myQueryString[$key] = $value;
  }

  function reset(){
    $this->myQueryString = $this->original;
  }

  function to_string(){
    if(is_array($this->myQueryString)){
      foreach($this->myQueryString as $key => $value){
        if($str_ret == ""){
          $str_ret = "?". $key . "=" . urlencode($value) ;
        }else{
          $str_ret .= "&". $key . "=" . urlencode($value) ;
        }
      }
    }
    return $str_ret;
  }

}

I'd like to add that this was working before I moved my application to adifferent machine / server.

The biggest difference is that I went from php 5.3 to php 5.5.9

I'm not sure why it is now not being recognized.

Upvotes: 0

Views: 1191

Answers (1)

Luis &#193;vila
Luis &#193;vila

Reputation: 699

Please change the <? to <?php in the beginning of the querystring class' file.
Some servers do not recognize <? as PHP, being recommended the use of <?php instead.

Upvotes: 1

Related Questions