K 
		
				
			
		KAOSNORMAL
Gamma
Verificado por Whatsapp
¡Usuario con pocos negocios! ¡Utiliza siempre saldo de Forobeta!
		hola que tal ps me cambie de servidor no creo aver movido nada a estos archivos solo lo unico que cambio fue que uso un phpadmin mas actualizado y en mi pagina me da este error que antes no salia 
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/cap01/public_html/include/database.php on line 20
Warning: Cannot modify header information - headers already sent by (output started at /home/cap01/public_html/include/database.php:20) in /home/cap01/public_html/include/session.php on line 113
Warning: Cannot modify header information - headers already sent by (output started at /home/cap01public_html/include/database.php:20) in /home/cap01/public_html/process.php on line 29
Este es mi archivo del database.php
	
	
	
		
Este es el de session.php
	
	
	
		
Este el de process.php
	
	
	
		
	
		
			
		
		
	
				
			Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/cap01/public_html/include/database.php on line 20
Warning: Cannot modify header information - headers already sent by (output started at /home/cap01/public_html/include/database.php:20) in /home/cap01/public_html/include/session.php on line 113
Warning: Cannot modify header information - headers already sent by (output started at /home/cap01public_html/include/database.php:20) in /home/cap01/public_html/process.php on line 29
Este es mi archivo del database.php
		PHP:
	
	<?php
include("constants.php");
define('TBL_ATTEMPTS','login_attempts');
define('TBL_USERS','users');
define('ATTEMPTS_NUMBER',10);
class MySQLDB
{
   var $connection;         //The MySQL database connection
   function MySQLDB(){
      $this->connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS) or die(mysql_error());
      mysql_select_db(DB_NAME, $this->connection) or die(mysql_error());
   }
   function confirmIPAddress($value) {
	$q = "SELECT attempts, (CASE when lastlogin is not NULL and DATE_ADD(LastLogin, INTERVAL 10 MINUTE)>NOW() then 1 else 0 end) as Denied ".
   " FROM `login_attempts` WHERE ip = '$value'";
 
   $result = mysql_query($q, $this->connection);
   $data = mysql_fetch_array($result);   
 
   //Verify that at least one login attempt is in database
   if (!$data) {
     return 0;
   } 
   if ($data["attempts"] >= ATTEMPTS_NUMBER)
   {
      if($data["Denied"] == 1)
      {
         return 1;
      }
     else
     {
        $this->clearLoginAttempts($value);
        return 0;
     }
   }
   return 0;  
  }
   
   function addLoginAttempt($value) {
   // increase number of attempts
   // set last login attempt time if required    
	  $q = "SELECT * FROM ".TBL_ATTEMPTS." WHERE ip = '$value'"; 
	  $result = mysql_query($q, $this->connection);
	  $data = mysql_fetch_array($result);
	  
	  if($data)
      {
        $attempts = $data["attempts"]+1;
        if($attempts==3) {
		 $q = "UPDATE ".TBL_ATTEMPTS." SET attempts=".$attempts.", lastlogin=NOW() WHERE ip = '$value'";
		 $result = mysql_query($q, $this->connection);
		}
        else {
		 $q = "UPDATE ".TBL_ATTEMPTS." SET attempts=".$attempts." WHERE ip = '$value'";
		 $result = mysql_query($q, $this->connection);
		}
       }
      else {
	   $q = "INSERT INTO ".TBL_ATTEMPTS." (attempts,IP,lastlogin) values (1, '$value', NOW())";
	   $result = mysql_query($q, $this->connection);
	  }
    }
   
   
   function confirmUserPass($username, $password){
      /* Add slashes if necessary (for query) */
      if(!get_magic_quotes_gpc()) {
	      $username = addslashes($username);
      }
      /* Verify that user is in database */
      $q = "SELECT password FROM ".TBL_USERS." WHERE username = '$username'";	
      $result = mysql_query($q, $this->connection);
      if(!$result || (mysql_numrows($result) < 1)){
         return 1; //Indicates username failure
      }
      /* Retrieve password from result, strip slashes */
      $dbarray = mysql_fetch_array($result);
      $dbarray['password'] = stripslashes($dbarray['password']);
      $password = stripslashes($password);
      /* Validate that password is correct */
      if($password == $dbarray['password']){
         return 0; //Success! Username and password confirmed
      }
      else{
         return 1; //Indicates password failure
      }
   }
   
   function confirmUserName($username){
      /* Add slashes if necessary (for query) */
      if(!get_magic_quotes_gpc()) {
	      $username = addslashes($username);
      }
      /* Verify that user is in database */
      $q = "SELECT * FROM ".TBL_USERS." WHERE username = '$username'";
      $result = mysql_query($q, $this->connection);
      if(!$result || (mysql_numrows($result) < 1)){
         return 1; //Indicates username failure
      } 
	  
	  return 0;
   }
   
   function clearLoginAttempts($value) {
    $q = "UPDATE ".TBL_ATTEMPTS." SET attempts = 0 WHERE ip = '$value'"; 
	return mysql_query($q, $this->connection);
   }
   
   function getUserInfo($username){
      $q = "SELECT * FROM ".TBL_USERS." WHERE username = '$username'";
      $result = mysql_query($q, $this->connection);
      /* Error occurred, return given name by default */
      if(!$result || (mysql_numrows($result) < 1)){
         return NULL;
      }
      /* Return result array */
      $dbarray = mysql_fetch_array($result);
      return $dbarray;
   }
      
   function displayUsers(){
   $q = "SELECT username,password "
       ."FROM ".TBL_USERS." ORDER BY username";
   $result = mysql_query($q, $this->connection);
   $num_rows = mysql_numrows($result);
   if($num_rows == 0){
      echo "Users table is empty";
      return;
   }
   echo "<p><table align=\"left\" border=\"1\" cellspacing=\"1\" cellpadding=\"1\">\n";
   echo "<tr><td class=\"tableheadprop\"> Username </td><td class=\"tableheadprop\"> Password </td></tr>\n";
   for($i=0; $i<$num_rows; $i++){
      $uname  = mysql_result($result,$i,"username");
      $upass = mysql_result($result,$i,"password");
      echo "<tr><td class=\"tableprop\">$uname</td><td class=\"tableprop\">$upass</td></tr>\n";
   }
   echo "</table></p><br>\n";
   }
   
   function displayAttempts($value){
   $q = "SELECT ip, attempts,lastlogin "
       ."FROM ".TBL_ATTEMPTS." WHERE ip = '$value' ORDER BY lastlogin";
   $result = mysql_query($q, $this->connection);
   $num_rows = mysql_numrows($result);
   if($num_rows == 0){
      echo "LoginAttempts table is empty";
      return;
   }
   echo "<p><table align=\"left\" border=\"1\" cellspacing=\"1\" cellpadding=\"1\">\n";
   echo "<tr><td class=\"tableheadprop\"> Your IP Address </td><td class=\"tableheadprop\"> Attempts </td><td class=\"tableheadprop\"> LastLogin </td></tr>\n";
   for($i=0; $i<$num_rows; $i++){
      $uip  = mysql_result($result,$i,"ip");
      $uattempt = mysql_result($result,$i,"attempts");
	  $ulogin = mysql_result($result,$i,"lastlogin");
	  
      echo "<tr><td class=\"tableprop\">$uip</td><td class=\"tableprop\">$uattempt</td><td class=\"tableprop\">$ulogin</td></tr>\n";
   }
   echo "</table></p><br>\n";
   }
};
/* Create database connection */
$database = new MySQLDB;
?>
	Este es el de session.php
		PHP:
	
	<?php
include("database.php");
include("form.php");
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
   var $ip;                  //Remote IP address  
   function Session(){
      $this->ip = $_SERVER["REMOTE_ADDR"];
      $this->time = time();
      $this->startSession();
   }
   function startSession(){
      global $database;  
      session_start();   
	  
      /* Determine if user is logged in */
      $this->logged_in = $this->checkLogin();
      /* Set referrer page */
      if(isset($_SESSION['url'])){
         $this->referrer = $_SESSION['url'];
      }else{
         $this->referrer = "/";
      }
      /* Set current url */
      $this->url = $_SESSION['url'] = $_SERVER['PHP_SELF'];
   }
   function checkLogin(){
      global $database; 
      /* Check if user has been remembered */
      if(isset($_COOKIE['cookname'])){
         $this->username = $_SESSION['username'] = $_COOKIE['cookname'];
      }
      if(isset($_SESSION['username'])){
         if($database->confirmUserName($_SESSION['username']) != 0){
            unset($_SESSION['username']);
            return false;
         }
         $this->userinfo  = $database->getUserInfo($_SESSION['username']);
         $this->username  = $this->userinfo['username'];
         return true;
      }
      else{
         return false;
      }
   }
   function login($subuser, $subpass, $subremember){
      global $database, $form;  
		
	  unset($form->errors);
	  /* Checks if this IP address is currently blocked*/	
      $result = $database->confirmIPAddress($this->ip);
      if($result == 1){
         $error_type = "access";
         $form->setError($error_type, "Access denied for ".TIME_PERIOD." minutes");
      } 
	  /* Return if form errors exist */
      if($form->num_errors > 0){
         return false;
      }
	  
	  $error_type = "attempt";
	  /* Username and password error checking */
      if(!$subuser || !$subpass || strlen($subuser = trim($subuser)) == 0){
         $form->setError($error_type, "Username or password not entered");
      }
	  
      if($form->num_errors > 0){
         return false;
      }
      /* Checks that username is in database and password is correct */
      $subuser = stripslashes($subuser);
      $result = $database->confirmUserPass($subuser, $subpass);
      if($result == 1){
         $form->setError($error_type, "Invalid username or password.");
		 $database->addLoginAttempt($this->ip);
      }
	  
      if($form->num_errors > 0){
         return false;
      }
      /* Username and password correct, register session variables */
      $this->userinfo  = $database->getUserInfo($subuser);
      $this->username  = $_SESSION['username'] = $this->userinfo['username'];
      
      /* Null login attempts */
	  $database->clearLoginAttempts($this->ip);
	  if($subremember){
         setcookie("cookname", $this->username, time()+COOKIE_EXPIRE, COOKIE_PATH);
      }
      /* Login completed successfully */
      return true;
   }
   function logout(){
      global $database;  
      if(isset($_COOKIE['cookname'])){
         setcookie("cookname", "", time()-COOKIE_EXPIRE, COOKIE_PATH);
      }
      unset($_SESSION['username']);
      $this->logged_in = false;
      
   }
};
/* Initialize session object */
$session = new Session;
/* Initialize form object */
$form = new Form;
?>
	Este el de process.php
		PHP:
	
	<?php
include("include/session.php");
class Process
{
   function Process(){
      global $session;
      if(isset($_POST['sublogin'])){
         $this->procLogin();
      }
      else if($session->logged_in){
         $this->procLogout();
      }
      else{
          header("Location: ".$url);
       }
   }
   function procLogin(){
      global $session, $form;
      /* Login attempt */
      $retval = $session->login($_POST['user'], $_POST['pass'], isset($_POST['remember']));
      
      /* Login successful */
      if($retval){
		$url = $_POST['url'];
        header("Location: ".$url);
      }
      /* Login failed */
      else{
         $_SESSION['value_array'] = $_POST;
         $_SESSION['error_array'] = $form->getErrorArray();
		$url = $_POST['url'];
         header("Location: ".$url);
      }
   }
   
   function procLogout(){
      global $session;
      $retval = $session->logout();
      header("Location: index.php?loggedout=1");
   }
   
};
$process = new Process;
?>