Какво означава това

themes , модове , проблеми , инсталация
Post Reply
haus
Потребител
Потребител
Posts: 712
Joined: Tue May 25, 2010 12:12 pm

Какво означава това

Post by haus » Tue Sep 28, 2010 10:46 pm

Искам да попитам какво означава това

Code: Select all

Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\site\include\database.php on line 208

Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\site\include\database.php on line 219

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\AppServ\www\siteinclude\database.php:208) in C:\AppServ\www\site\include\session.php on line 46

Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\site\include\database.php on line 219

Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\site\include\database.php on line 208

Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\site\include\database.php on line 219

Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\site\include\database.php on line 136

Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\site\include\database.php:208) in C:\AppServ\www\site\process.php on line 111

User avatar
Soul_Stealler
Web-tourist
Web-tourist
Posts: 3559
Joined: Tue Dec 20, 2005 3:52 pm
Answers: 112
Location: София
Contact:

Post by Soul_Stealler » Tue Sep 28, 2010 10:48 pm

Заявката не ти е в ред и не може да преброи редовете :wink:

haus
Потребител
Потребител
Posts: 712
Joined: Tue May 25, 2010 12:12 pm

Post by haus » Tue Sep 28, 2010 10:51 pm

ще може ли да ми го оправиш pls ето кода

Code: Select all

<?
/**
 * Database.php
 * 
 * The Database class is meant to simplify the task of accessing
 * information from the website's database.
 *
 * Written by&#58; Jpmaster77 a.k.a. The Grandmaster of C++ &#40;GMC&#41;
 * Last Updated&#58; August 17, 2004
 */
include&#40;"constants.php"&#41;;
      
class MySQLDB
&#123;
   var $connection;         //The MySQL database connection
   var $num_active_users;   //Number of active users viewing site
   var $num_active_guests;  //Number of active guests viewing site
   var $num_members;        //Number of signed-up users
   /* Note&#58; call getNumMembers&#40;&#41; to access $num_members! */

   /* Class constructor */
   function MySQLDB&#40;&#41;&#123;
      /* Make connection to database */
      $this->connection = mysql_connect&#40;'localhost', 'root','parolata mi' &#41; or die&#40;mysql_error&#40;&#41;&#41;;
      mysql_select_db&#40;'databazata', $this->connection&#41; or die&#40;mysql_error&#40;&#41;&#41;;
      
      /**
       * Only query database to find out number of members
       * when getNumMembers&#40;&#41; is called for the first time,
       * until then, default value set.
       */
      $this->num_members = -1;
      
      if&#40;TRACK_VISITORS&#41;&#123;
         /* Calculate number of users at site */
         $this->calcNumActiveUsers&#40;&#41;;
      
         /* Calculate number of guests at site */
         $this->calcNumActiveGuests&#40;&#41;;
      &#125;
   &#125;

   /**
    * confirmUserPass - Checks whether or not the given
    * username is in the database, if so it checks if the
    * given password is the same password in the database
    * for that user. If the user doesn't exist or if the
    * passwords don't match up, it returns an error code
    * &#40;1 or 2&#41;. On success it returns 0.
    */
   function confirmUserPass&#40;$username, $password&#41;&#123;
      /* Add slashes if necessary &#40;for query&#41; */
      if&#40;!get_magic_quotes_gpc&#40;&#41;&#41; &#123;
	      $username = addslashes&#40;$username&#41;;
      &#125;

      /* Verify that user is in database */
      $q = "SELECT password FROM ".TBL_USERS." WHERE username = '$username'";
      $result = mysql_query&#40;$q, $this->connection&#41;;
      if&#40;!$result || &#40;mysql_numrows&#40;$result&#41; < 1&#41;&#41;&#123;
         return 1; //Indicates username failure
      &#125;

      /* Retrieve password from result, strip slashes */
      $dbarray = mysql_fetch_array&#40;$result&#41;;
      $dbarray&#91;'password'&#93; = stripslashes&#40;$dbarray&#91;'password'&#93;&#41;;
      $password = stripslashes&#40;$password&#41;;

      /* Validate that password is correct */
      if&#40;$password == $dbarray&#91;'password'&#93;&#41;&#123;
         return 0; //Success! Username and password confirmed
      &#125;
      else&#123;
         return 2; //Indicates password failure
      &#125;
   &#125;
   
   /**
    * confirmUserID - Checks whether or not the given
    * username is in the database, if so it checks if the
    * given userid is the same userid in the database
    * for that user. If the user doesn't exist or if the
    * userids don't match up, it returns an error code
    * &#40;1 or 2&#41;. On success it returns 0.
    */
   function confirmUserID&#40;$username, $userid&#41;&#123;
      /* Add slashes if necessary &#40;for query&#41; */
      if&#40;!get_magic_quotes_gpc&#40;&#41;&#41; &#123;
	      $username = addslashes&#40;$username&#41;;
      &#125;

      /* Verify that user is in database */
      $q = "SELECT userid FROM ".TBL_USERS." WHERE username = '$username'";
      $result = mysql_query&#40;$q, $this->connection&#41;;
      if&#40;!$result || &#40;mysql_numrows&#40;$result&#41; < 1&#41;&#41;&#123;
         return 1; //Indicates username failure
      &#125;

      /* Retrieve userid from result, strip slashes */
      $dbarray = mysql_fetch_array&#40;$result&#41;;
      $dbarray&#91;'userid'&#93; = stripslashes&#40;$dbarray&#91;'userid'&#93;&#41;;
      $userid = stripslashes&#40;$userid&#41;;

      /* Validate that userid is correct */
      if&#40;$userid == $dbarray&#91;'userid'&#93;&#41;&#123;
         return 0; //Success! Username and userid confirmed
      &#125;
      else&#123;
         return 2; //Indicates userid invalid
      &#125;
   &#125;
   
   /**
    * usernameTaken - Returns true if the username has
    * been taken by another user, false otherwise.
    */
   function usernameTaken&#40;$username&#41;&#123;
      if&#40;!get_magic_quotes_gpc&#40;&#41;&#41;&#123;
         $username = addslashes&#40;$username&#41;;
      &#125;
      $q = "SELECT username FROM ".TBL_USERS." WHERE username = '$username'";
      $result = mysql_query&#40;$q, $this->connection&#41;;
      return &#40;mysql_numrows&#40;$result&#41; > 0&#41;;
   &#125;
   
   /**
    * usernameBanned - Returns true if the username has
    * been banned by the administrator.
    */
   function usernameBanned&#40;$username&#41;&#123;
      if&#40;!get_magic_quotes_gpc&#40;&#41;&#41;&#123;
         $username = addslashes&#40;$username&#41;;
      &#125;
      $q = "SELECT username FROM ".TBL_BANNED_USERS." WHERE username = '$username'";
      $result = mysql_query&#40;$q, $this->connection&#41;;
      return &#40;mysql_numrows&#40;$result&#41; > 0&#41;;
   &#125;
   
   /**
    * addNewUser - Inserts the given &#40;username, password, email&#41;
    * info into the database. Appropriate user level is set.
    * Returns true on success, false otherwise.
    */
   function addNewUser&#40;$username, $password, $email, $меренге, $fname, $lname, $city&#41;&#123;
      $time = time&#40;&#41;;
      /* If admin sign up, give admin user level */
      if&#40;strcasecmp&#40;$username, ADMIN_NAME&#41; == 0&#41;&#123;
         $ulevel = ADMIN_LEVEL;
      &#125;else&#123;
         $ulevel = USER_LEVEL;
      &#125;
      $pic = "i/noavatar.gif";
      $q = "INSERT INTO ".TBL_USERS." VALUES &#40;'$username', '$password', '0', $ulevel, '$email', $time, '$fname', '$lname', '$меренге', '$pic', '$city', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '$pic', ''&#41;";
      return mysql_query&#40;$q, $this->connection&#41;;
   &#125;
   
   /**
    * updateUserField - Updates a field, specified by the field
    * parameter, in the user's row of the database.
    */
   function updateUserField&#40;$username, $field, $value&#41;&#123;
      $q = "UPDATE ".TBL_USERS." SET ".$field." = '$value' WHERE username = '$username'";
      return mysql_query&#40;$q, $this->connection&#41;;
   &#125;
   
   /**
    * getUserInfo - Returns the result array from a mysql
    * query asking for all information stored regarding
    * the given username. If query fails, NULL is returned.
    */
   function getUserInfo&#40;$username&#41;&#123;
      $q = "SELECT * FROM ".TBL_USERS." WHERE username = '$username'";
      $result = mysql_query&#40;$q, $this->connection&#41;;
      /* Error occurred, return given name by default */
      if&#40;!$result || &#40;mysql_numrows&#40;$result&#41; < 1&#41;&#41;&#123;
         return NULL;
      &#125;
      /* Return result array */
      $dbarray = mysql_fetch_array&#40;$result&#41;;
      return $dbarray;
   &#125;
   
   /**
    * getNumMembers - Returns the number of signed-up users
    * of the website, banned members not included. The first
    * time the function is called on page load, the database
    * is queried, on subsequent calls, the stored result
    * is returned. This is to improve efficiency, effectively
    * not querying the database when no call is made.
    */
   function getNumMembers&#40;&#41;&#123;
      if&#40;$this->num_members < 0&#41;&#123;
         $q = "SELECT * FROM ".TBL_USERS;
         $result = mysql_query&#40;$q, $this->connection&#41;;
         $this->num_members = mysql_numrows&#40;$result&#41;;
      &#125;
      return $this->num_members;
   &#125;
   
   /**
    * calcNumActiveUsers - Finds out how many active users
    * are viewing site and sets class variable accordingly.
    */
   function calcNumActiveUsers&#40;&#41;&#123;
      /* Calculate number of users at site */
      $q = "SELECT * FROM ".TBL_ACTIVE_USERS;
      $result = mysql_query&#40;$q, $this->connection&#41;;
      $this->num_active_users = mysql_numrows&#40;$result&#41;;
   &#125;
   
   /**
    * calcNumActiveGuests - Finds out how many active guests
    * are viewing site and sets class variable accordingly.
    */
   function calcNumActiveGuests&#40;&#41;&#123;
      /* Calculate number of guests at site */
      $q = "SELECT * FROM ".TBL_ACTIVE_GUESTS;
      $result = mysql_query&#40;$q, $this->connection&#41;;
      $this->num_active_guests = mysql_numrows&#40;$result&#41;;
   &#125;
   
   /**
    * addActiveUser - Updates username's last active timestamp
    * in the database, and also adds him to the table of
    * active users, or updates timestamp if already there.
    */
   function addActiveUser&#40;$username, $time&#41;&#123;
      $q = "UPDATE ".TBL_USERS." SET timestamp = '$time' WHERE username = '$username'";
      mysql_query&#40;$q, $this->connection&#41;;
      
      if&#40;!TRACK_VISITORS&#41; return;
      $q = "REPLACE INTO ".TBL_ACTIVE_USERS." VALUES &#40;'$username', '$time'&#41;";
      mysql_query&#40;$q, $this->connection&#41;;
      $this->calcNumActiveUsers&#40;&#41;;
   &#125;
   
   /* addActiveGuest - Adds guest to active guests table */
   function addActiveGuest&#40;$ip, $time&#41;&#123;
      if&#40;!TRACK_VISITORS&#41; return;
      $q = "REPLACE INTO ".TBL_ACTIVE_GUESTS." VALUES &#40;'$ip', '$time'&#41;";
      mysql_query&#40;$q, $this->connection&#41;;
      $this->calcNumActiveGuests&#40;&#41;;
   &#125;
   
   /* These functions are self explanatory, no need for comments */
   
   /* removeActiveUser */
   function removeActiveUser&#40;$username&#41;&#123;
      if&#40;!TRACK_VISITORS&#41; return;
      $q = "DELETE FROM ".TBL_ACTIVE_USERS." WHERE username = '$username'";
      mysql_query&#40;$q, $this->connection&#41;;
      $this->calcNumActiveUsers&#40;&#41;;
   &#125;
   
   /* removeActiveGuest */
   function removeActiveGuest&#40;$ip&#41;&#123;
      if&#40;!TRACK_VISITORS&#41; return;
      $q = "DELETE FROM ".TBL_ACTIVE_GUESTS." WHERE ip = '$ip'";
      mysql_query&#40;$q, $this->connection&#41;;
      $this->calcNumActiveGuests&#40;&#41;;
   &#125;
   
   /* removeInactiveUsers */
   function removeInactiveUsers&#40;&#41;&#123;
      if&#40;!TRACK_VISITORS&#41; return;
      $timeout = time&#40;&#41;-USER_TIMEOUT*60;
      $q = "DELETE FROM ".TBL_ACTIVE_USERS." WHERE timestamp < $timeout";
      mysql_query&#40;$q, $this->connection&#41;;
      $this->calcNumActiveUsers&#40;&#41;;
   &#125;

   /* removeInactiveGuests */
   function removeInactiveGuests&#40;&#41;&#123;
      if&#40;!TRACK_VISITORS&#41; return;
      $timeout = time&#40;&#41;-GUEST_TIMEOUT*60;
      $q = "DELETE FROM ".TBL_ACTIVE_GUESTS." WHERE timestamp < $timeout";
      mysql_query&#40;$q, $this->connection&#41;;
      $this->calcNumActiveGuests&#40;&#41;;
   &#125;
   
   /**
    * query - Performs the given query on the database and
    * returns the result, which may be false, true or a
    * resource identifier.
    */
   function query&#40;$query&#41;&#123;
      return mysql_query&#40;$query, $this->connection&#41;;
   &#125;
&#125;;

/* Create database connection */
$database = new MySQLDB;

?>

Post Reply