Проблем с файлове

martinesko36

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

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

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

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

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

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

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

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\Perni4ani.ORG\index.php on line 8

Toва е проблема, във конфига съм направил всичко както трябва, ала в database.php не виждам изобщо никакви свързвания.Давам +1.Ето кода на database.php:
Код:
<?
/**
 * Database.php
 * 
 * The Database class is meant to simplify the task of accessing
 * information from the website's database.
 *
 * Written by: Jpmaster77 a.k.a. The Grandmaster of C++ (GMC)
 * Last Updated: August 17, 2004
 */
include("constants.php");
      
class MySQLDB
{
   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: call getNumMembers() to access $num_members! */

   /* Class constructor */
   function MySQLDB(){
      /* Make connection to database */
      $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());
      
      /**
       * Only query database to find out number of members
       * when getNumMembers() is called for the first time,
       * until then, default value set.
       */
      $this->num_members = -1;
      
      if(TRACK_VISITORS){
         /* Calculate number of users at site */
         $this->calcNumActiveUsers();
      
         /* Calculate number of guests at site */
         $this->calcNumActiveGuests();
      }
   }

   /**
    * 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
    * (1 or 2). On success it returns 0.
    */
   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 2; //Indicates password failure
      }
   }
   
   /**
    * 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
    * (1 or 2). On success it returns 0.
    */
   function confirmUserID($username, $userid){
      /* Add slashes if necessary (for query) */
      if(!get_magic_quotes_gpc()) {
	      $username = addslashes($username);
      }

      /* Verify that user is in database */
      $q = "SELECT userid FROM ".TBL_USERS." WHERE username = '$username'";
      $result = mysql_query($q, $this->connection);
      if(!$result || (mysql_numrows($result) < 1)){
         return 1; //Indicates username failure
      }

      /* Retrieve userid from result, strip slashes */
      $dbarray = mysql_fetch_array($result);
      $dbarray['userid'] = stripslashes($dbarray['userid']);
      $userid = stripslashes($userid);

      /* Validate that userid is correct */
      if($userid == $dbarray['userid']){
         return 0; //Success! Username and userid confirmed
      }
      else{
         return 2; //Indicates userid invalid
      }
   }
   
   /**
    * usernameTaken - Returns true if the username has
    * been taken by another user, false otherwise.
    */
   function usernameTaken($username){
      if(!get_magic_quotes_gpc()){
         $username = addslashes($username);
      }
      $q = "SELECT username FROM ".TBL_USERS." WHERE username = '$username'";
      $result = mysql_query($q, $this->connection);
      return (mysql_numrows($result) > 0);
   }
   
   /**
    * usernameBanned - Returns true if the username has
    * been banned by the administrator.
    */
   function usernameBanned($username){
      if(!get_magic_quotes_gpc()){
         $username = addslashes($username);
      }
      $q = "SELECT username FROM ".TBL_BANNED_USERS." WHERE username = '$username'";
      $result = mysql_query($q, $this->connection);
      return (mysql_numrows($result) > 0);
   }
   
   /**
    * addNewUser - Inserts the given (username, password, email)
    * info into the database. Appropriate user level is set.
    * Returns true on success, false otherwise.
    */
   function addNewUser($username, $password, $email, $sex, $fname, $lname, $city){
      $time = time();
      /* If admin sign up, give admin user level */
      if(strcasecmp($username, ADMIN_NAME) == 0){
         $ulevel = ADMIN_LEVEL;
      }else{
         $ulevel = USER_LEVEL;
      }
      $pic = "i/noavatar.gif";
      $q = "INSERT INTO ".TBL_USERS." VALUES ('$username', '$password', '0', $ulevel, '$email', $time, '$fname', '$lname', '$sex', '$pic', '$city', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '$pic', '')";
      return mysql_query($q, $this->connection);
   }
   
   /**
    * updateUserField - Updates a field, specified by the field
    * parameter, in the user's row of the database.
    */
   function updateUserField($username, $field, $value){
      $q = "UPDATE ".TBL_USERS." SET ".$field." = '$value' WHERE username = '$username'";
      return mysql_query($q, $this->connection);
   }
   
   /**
    * 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($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;
   }
   
   /**
    * 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(){
      if($this->num_members < 0){
         $q = "SELECT * FROM ".TBL_USERS;
         $result = mysql_query($q, $this->connection);
         $this->num_members = mysql_numrows($result);
      }
      return $this->num_members;
   }
   
   /**
    * calcNumActiveUsers - Finds out how many active users
    * are viewing site and sets class variable accordingly.
    */
   function calcNumActiveUsers(){
      /* Calculate number of users at site */
      $q = "SELECT * FROM ".TBL_ACTIVE_USERS;
      $result = mysql_query($q, $this->connection);
      $this->num_active_users = mysql_numrows($result);
   }
   
   /**
    * calcNumActiveGuests - Finds out how many active guests
    * are viewing site and sets class variable accordingly.
    */
   function calcNumActiveGuests(){
      /* Calculate number of guests at site */
      $q = "SELECT * FROM ".TBL_ACTIVE_GUESTS;
      $result = mysql_query($q, $this->connection);
      $this->num_active_guests = mysql_numrows($result);
   }
   
   /**
    * 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($username, $time){
      $q = "UPDATE ".TBL_USERS." SET timestamp = '$time' WHERE username = '$username'";
      mysql_query($q, $this->connection);
      
      if(!TRACK_VISITORS) return;
      $q = "REPLACE INTO ".TBL_ACTIVE_USERS." VALUES ('$username', '$time')";
      mysql_query($q, $this->connection);
      $this->calcNumActiveUsers();
   }
   
   /* addActiveGuest - Adds guest to active guests table */
   function addActiveGuest($ip, $time){
      if(!TRACK_VISITORS) return;
      $q = "REPLACE INTO ".TBL_ACTIVE_GUESTS." VALUES ('$ip', '$time')";
      mysql_query($q, $this->connection);
      $this->calcNumActiveGuests();
   }
   
   /* These functions are self explanatory, no need for comments */
   
   /* removeActiveUser */
   function removeActiveUser($username){
      if(!TRACK_VISITORS) return;
      $q = "DELETE FROM ".TBL_ACTIVE_USERS." WHERE username = '$username'";
      mysql_query($q, $this->connection);
      $this->calcNumActiveUsers();
   }
   
   /* removeActiveGuest */
   function removeActiveGuest($ip){
      if(!TRACK_VISITORS) return;
      $q = "DELETE FROM ".TBL_ACTIVE_GUESTS." WHERE ip = '$ip'";
      mysql_query($q, $this->connection);
      $this->calcNumActiveGuests();
   }
   
   /* removeInactiveUsers */
   function removeInactiveUsers(){
      if(!TRACK_VISITORS) return;
      $timeout = time()-USER_TIMEOUT*60;
      $q = "DELETE FROM ".TBL_ACTIVE_USERS." WHERE timestamp < $timeout";
      mysql_query($q, $this->connection);
      $this->calcNumActiveUsers();
   }

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

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

?>

Ето и на ндекса:
Код:
<?php
include("include/session.php");
include("lang/bg.lang");
$poll1 = $_POST['poll_vote'];
$vote = $_GET['vote'];

$sql2 = mysql_query("SELECT * FROM `poll` ORDER by `id` DESC");
$poll = mysql_fetch_array($sql2);
$ip = $_SERVER['REMOTE_ADDR'];
if($vote==1) {
$q = mysql_query("INSERT INTO `poll_vote` VALUES('', '$poll[id]', '$poll1', '$ip')"); }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
	<meta name="author" content="http://waisys.net/">
	<title><?php echo $lang['title']; ?></title>
	<link rel="shortcut icon" href="i/icon.gif">
	<link href="facefiles/facebox.css" media="screen" rel="stylesheet" type="text/css">
	<script src="facefiles/jquery-1.2.2.pack.js" type="text/javascript"></script>
	<script src="facefiles/facebox.js" type="text/javascript"></script>
	<script type="text/javascript" src="js/comment.js"></script>
	<script type="text/javascript" src="js/over.js"></script>
	<script type="text/javascript" src="js/func.js"></script>
	<script type="text/javascript" src="js/prototype.js"></script>
	<link href="i/main.css" rel="stylesheet" type="text/css">
	<?php require_once('include/function.php'); ?>
<link rel="stylesheet" type="text/css" href="inews/css.css">



<script type="text/javascript" src="inews/jquery-comp.js"></script>


</head>
<body>
<div id="container">
<?php include('include/header.php'); ?>
<div style="padding-left:0px;">
<div id="content" style="padding-top:50px;" align="left">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<?php include("last_news.php"); ?><br>
<center>

<script src="http://localhost/adv/view.php?id=1" type="text/javascript"></script>

</center>
<br>
<div class="topusersbar"></div>
<div class="topuserspanel">
<div style="padding-left:35px;">
<?php 
$q = "SELECT * FROM `users` ORDER by `points` DESC LIMIT 4";
$result = $database->query($q);
$num_rows = mysql_numrows($result);
if(!$result || ($num_rows < 0)){
   echo "Error displaying info";
}
else if($num_rows > 0){
   for($i=0; $i<$num_rows; $i++){
      $uname = mysql_result($result,$i,"username");
      $pic = mysql_result($result,$i,"pic");
      $sex = mysql_result($result,$i,"sex");
      $points = mysql_result($result,$i,"points");
      if($sex=='m') {
	  ?>
<a href="userinfo.php?user=<?php echo $uname; ?>"><img src="<?php echo $pic;?>" width="130" height="158" style="border:2px solid #13B1E1;"></a>
<?php } else { ?>
<a href="userinfo.php?user=<?php echo $uname; ?>"><img src="<?php echo $pic;?>" width="130" height="158" style="border:2px solid #E22BAB;"></a>
<?php }
   }
}
?></div>
</div>

<div class="lastbar"></div>
<div class="lastpanel">
<div style="padding-left:35px;">
<?php 
$q = "SELECT * FROM `pics` ORDER by `id` DESC LIMIT 4";
$result = $database->query($q);
$num_rows = mysql_numrows($result);
if(!$result || ($num_rows < 0)){
   echo "Error displaying info";
}
else if($num_rows > 0){
   for($i=0; $i<$num_rows; $i++){
      $uname = mysql_result($result,$i,"user");
      $pic = mysql_result($result,$i,"link");

      if($sex=='m') {
	  ?>
<a href="userinfo.php?user=<?php echo $uname; ?>"><img src="<?php echo $pic;?>" width="130" height="158" style="border:2px solid #13B1E1;"></a>
<?php } else { ?>
<a href="userinfo.php?user=<?php echo $uname; ?>"><img src="<?php echo $pic;?>" width="130" height="158" style="border:2px solid #E22BAB;"></a>
<?php }
   }
}
?></div>
</div>
<br><center>

<script src="http://localhost/adv/view.php?id=3" type="text/javascript"></script>

</center><br>
<div class="lastubar"></div>
<div class="lastupanel">
<div style="padding-left:35px;">
<?php 
$qa = mysql_query("SELECT COUNT(*) AS br FROM `users`");
$aa = mysql_fetch_array($qa);
$a = $aa['br'] - 4;
$q = "SELECT * FROM `users` LIMIT $a, 4";
$result = $database->query($q);
$num_rows = mysql_numrows($result);
if(!$result || ($num_rows < 0)){
   echo "Error displaying info";
}
else if($num_rows > 0){
   for($i=0; $i<$num_rows; $i++){
      $uname = mysql_result($result,$i,"username");
      $pic = mysql_result($result,$i,"pic");
      $sex = mysql_result($result,$i,"sex");
      $points = mysql_result($result,$i,"points");
      if($sex=='m') {
	  ?>
<a href="userinfo.php?user=<?php echo $uname; ?>"><img src="<?php echo $pic;?>" width="130" height="158" style="border:2px solid #13B1E1;"></a>
<?php } else { ?>
<a href="userinfo.php?user=<?php echo $uname; ?>"><img src="<?php echo $pic;?>" width="130" height="158" style="border:2px solid #E22BAB;"></a>
<?php }
   }
}
?></div>
</div>

</td>

<td valign="top" align="right">
<?php 
if(!$session->logged_in) {
?>
<div class="vhodbar-index"></div>
<div style="padding-left:31px;"><div class="vhodpanel" align="center">
<form action="process.php" method="POST">
<table align="center" border="0" cellspacing="5" cellpadding="3">
<tr><td><input id="user" type="text" name="user" maxlength="30" value=""></td></tr><tr><td><? echo $form->error("user"); ?></td></tr>
<tr><td><input id="pass" type="password" name="pass" maxlength="30" value=""></td></tr><tr><td><? echo $form->error("pass"); ?></td></tr><tr><td align="center">
<input type="checkbox" name="remember" <? if($form->value("remember") != ""){ echo "checked"; } ?>>
<font size="2"> Запомни ме</td></tr></table>
<input type="hidden" name="sublogin" value="1">
<input type="submit" value="" id="vhod">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td><font size="2"><a href="forgotpass.php" id="reg">Забравена парола?</a></font></td>
<td style="padding-left:20px;"><a href="register.php" id="reg"><font size="2">Регистрирай се!</font></a></td>
</tr>
</table>
</form>
</div></div>
<?php 
} else { 
$req_user_info = $database->getUserInfo($session->username);
?>
<div style="padding-top:30px;">
<div class="userbar"></div>
<div style=" padding-left:31px;">
<div class="userpanel">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td><img src="<?php echo $req_user_info['pic']; ?>" border="2px solid #000" width="130" height="150"></td>
<td valign="top" style="padding-left:15px; color:#777777; font-size:14px;">
<?php include('include/islogged.php'); ?>		
</td>
</tr>
</table>
</div></div>
<?php } ?>
<br>
<center>	

<script src="http://localhost/adv/view.php?id=2" type="text/javascript"></script>


</center>
<br>
<div class="searchbar"></div>
<div class="searchpanel" align="center">
<?php include("include/sform.php"); ?>
</div>
<br>
<div class="poolhbar"></div>
<div class="poolpanel" align="center">


<?php 
$sql2 = mysql_query("SELECT * FROM `poll` ORDER by `id` DESC");
$poll = mysql_fetch_array($sql2);
$sql3 = mysql_query("SELECT * FROM `poll_vote` WHERE `poll_id`='$poll[id]' and `ip`='$ip'");
$num = mysql_numrows($sql3);
if($num==0) { ?>			
<div class="poll_q"><?php echo $poll['q']; ?><br><br>
<table>
<tr>
<td align="left" colspan="3">
<form action="?vote=1" method="post">
<p class="positive"><input type="radio" value="0" name="poll_vote"><?php echo $poll['a1']; ?></p>
</td>
</tr>
<tr>
<td align="left"  colspan="3"><p class="negative"><input type="radio" value="1" name="poll_vote"><?php echo $poll['a2']; ?></p>
</td>
</tr>
</table>		
</div>										
<div class="poll_btn"><input class="btn" value="" type="submit"></form></div>	
<?php } else {?>
<div class="poll_q"><?php echo $poll['q']; ?><br><br>
<?php
$q = mysql_query("SELECT * FROM `poll_vote` WHERE `poll_id`='$poll[id]' and `vote`='0'");
$pos = mysql_numrows($q);
$q1 = mysql_query("SELECT * FROM `poll_vote` WHERE `poll_id`='$poll[id]' and `vote`='1'");
$neg = mysql_numrows($q1);
$q2 = mysql_query("SELECT * FROM `poll_vote` WHERE `poll_id`='$poll[id]'");
$total = mysql_numrows($q2);
$posp = (($pos/$total) * 100) / 1.4;
$posp1 = round((($pos/$total) * 100));
$negp = (($neg/$total) * 100) / 1.4;
$negp1 = round((($neg/$total) * 100));
$w1 = $posp;
$w2 = $negp;
if($w1 <= 0) {$w1=5;}
if($w2 <= 0) {$w2=5;}
?>
<table>
<tr>
<td align="left" colspan="3">
<p class="positive">
<?php echo "$poll[a1]<br><img src=\"i/index/poll.PNG\" width=\"$w1%\" height=\"8px\"> $posp1%"; ?>
</p>
</td>
</tr>
<tr>
<td align="left"  colspan="3">
<p class="negative">
<?php echo "$poll[a2]<br><img src=\"i/index/poll.PNG\" width=\"$w2%\" height=\"8px\"> $negp1%"; ?>
</p>
</td>
</tr>
</table>		
</div>	

<?php } ?>	


</div>
</td>
</tr>
</table>
</div><?php include('include/footer.php'); ?>
</div></div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-6809195-1");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
</html>
[/code]
 

Back
Горе