Jump to content

Recently Moved Website


poison6feet

Recommended Posts

Hi,

Earlier I was hosting my website on VPS and written in PHP, recently I moved this site to only webhosting services but due to some reason, the code is not responding and working properly.

For example,

I have used process.php to handle forms and session.php to handle session variables and database.php to handle data manupilations, but when I trying to add the user then I am getting this error, Fatal error: Call to undefined method MySQLDB::adduser(), however this was working fine.

 

Thanks

 

Link to comment
Share on other sites

SORRY For unorganized CODE Formatting

 

 

class Session

{

  var $username;    //Username given on sign-up

  var $userid;      //Random value generated on current login

  var $userlevel;    //The level to which the user pertains

  var $time;        //Time user was last active (page loaded)

  var $logged_in;    //True if user is logged in, false otherwise

  var $userinfo = array();  //The array holding all user info

  var $url;          //The page url current being viewed

  var $referrer;    //Last recorded site page viewed

 

 

  /* Class constructor */

  function Session(){

      $this->time = time();

      $this->startSession();

  }

 

 

function startSession(){

      global $database;  //The database connection

      session_start();  //Tell PHP to start the session

 

      /* Determine if user is logged in */

      $this->logged_in = $this->checkLogin();

 

      /**

      * Set guest value to users not logged in, and update

      * active guests table accordingly.

      */

      if(!$this->logged_in){

        $this->username = $_SESSION['username'] = GUEST_NAME;

        $this->userlevel = GUEST_LEVEL;

        $database->addActiveGuest($_SERVER['REMOTE_ADDR'], $this->time);

      }

      /* Update users last active timestamp */

      else{

        $database->addActiveUser($this->username, $this->time);

      }

 

      /* Remove inactive visitors from database */

      $database->removeInactiveUsers();

      $database->removeInactiveGuests();

 

      /* Set referrer page */

      if(isset($_SESSION['url'])){

        $this->referrer = $_SESSION['url'];

      }else{

        $this->referrer = "/";

      }

 

      /* Set current url */

      $this->url = $_SESSION['url'] = $_SERVER['PHP_SELF'];

  }

Link to comment
Share on other sites

Sorry, I meant to ask to see where you instantiate the session object. You don't seem to in any of the code you have posted.

 

Also, there is no updatestats() or adduser() methods within this class.

Link to comment
Share on other sites

On index page and login page and all other pages I have started the session

session_start();

include("include/session.php");

 

 

with in the Session.php file

 

 

  /* Update Statistics*/

 

function updatestats($username, $page){

global $database;

//echo "Entered";

return $database->updatestats($username, $page);

}

 

 

with in the database.php file

 

  /**

    * update daily stats

    */

  function updatestats($username, $page){

  $ip=$_SERVER['REMOTE_ADDR'];

  if ($username){

  $loggedin=$username;

  }

  else

  {

  $loggedin="Guest";

  }

  $datetime = getdate();

  $date = $datetime[mday]."/".$datetime[mon]."/".$datetime[year];

$time=$datetime[hours].":".$datetime[minutes].":".$datetime[seconds];

$page=str_replace("'","''",$page);

//echo $page;

      $q = "SELECT count FROM statistics where ipaddress = '$ip' and date='$date' and page='$page'";

 

      $result = mysql_query($q, $this->connection);

 

      if (mysql_numrows($result) > 0){

$row_count = mysql_fetch_assoc($result);

$count=$row_count['count']+1;

$q="Update statistics set LatestTime='$time', count=$count Where ipaddress = '$ip' and date='$date' and page='$page'";

      }

      else

      {

            $q = "Insert into statistics values('','$ip','$loggedin','$page','$date','$time','$time',1)";

 

      }

 

return mysql_query($q, $this->connection);

 

  }

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.