Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: co to oznacz ?
Forum PHP.pl > Forum > Przedszkole
mefjiu
mam skrypt logowania dziala nrmalnie ale jak go inluduje do indexu to wywala mi sie taki bład
Kod
Fatal error: Cannot redeclare class customsql in C:\Program Files\WebServ\httpd\CustomSql.inc.php on line 86


podam pliczek z bledem

  1. <?php
  2.  
  3.  
  4.  
  5. require("./DbSql.inc.php");
  6.  
  7. Class CustomSQL extends DBSQL
  8. {
  9.  // the constructor
  10.  function CustomSQL($DBName = "")
  11.  {
  12. $this->DBSQL($DBName);
  13.  }
  14.  
  15.  function checkusername($username)
  16.  {
  17. $sql = "select customerid from customer where username='$username'";
  18. $result = $this->select($sql);
  19. return $result;
  20.  }
  21.  
  22.  function adduser($username,$password,$email,$homepage,$icq,$aol,$yahoo,$msn,$location,$occupation,$interests,$biography)
  23.  {
  24. $sql = "insert into customer (username,password,email,homepage,icq,aol,yahoo,msn,location,occupation,inte
    rests,biography) values ('$username','$password','$email','$homepage','$icq','$aol','$yahoo','$msn','$location','$occupation','$interests','$biography')"
    ;
  25. $result = $this->insert($sql);
  26. return $result;
  27.  }
  28.  
  29.  function logincheck($username,$password)
  30.  {
  31. $sql = "select customerid from customer where username='$username' and password='$password'";
  32. $result = $this->select($sql);
  33. if (empty($result)) {
  34. return 0;
  35. }else{
  36. $CID = $result[0]["customerid"];
  37. return $CID;
  38. }
  39.  }
  40.  
  41.  function checkpassword($customerid,$password)
  42.  {
  43. $sql = "select customerid from customer where password='$password' and customerid='$customerid'";
  44. $result = $this->select($sql);
  45. if (empty($result)) {
  46. return 0;
  47. }else{
  48. $CID = $result[0]["customerid"];
  49. return $CID;
  50. }
  51.  }
  52.  
  53.  function emailcheck($email)
  54.  {
  55. $sql = "select password from customer where email='$email'";
  56. $result = $this->select($sql);
  57. if (empty($result)) {
  58. return 0;
  59. }else{
  60. $password = $result[0]["password"];
  61. return $password;
  62. }
  63.  }
  64.  
  65.  function getuserinfobyid($customerid)
  66.  {
  67. $sql = "select * from customer where customerid='$customerid'";
  68. $result = $this->select($sql);
  69. return $result;
  70.  }
  71.  
  72.  function edituser($email,$homepage,$icq,$aol,$yahoo,$msn,$location,$occupation,$interests,$biography,$customerid)
  73.  {
  74. $sql = "update customer set email='$email',homepage='$homepage',icq='$icq',aol='$aol',yahoo='$yahoo',msn='$msn',location='$location',occupation='$occupation',interests='$interests',biography='$biography' where customerid='$customerid'";
  75. $results = $this->update($sql);
  76. return $results;
  77.  }
  78.  
  79.  function modifypass($password,$customerid)
  80.  {
  81. $sql = "update customer set password='$password' where customerid='$customerid'";
  82. $results = $this->update($sql);
  83. return $results;
  84.  }
  85.  
  86. }
  87.  
  88. ?>


co mam z tym zrobic questionmark.gif
NetJaro
Ale jak do includujesz? Wykonujesz po zaincludowaniu jakieś operacje oparte o tą klasę?
mefjiu
includuje to normalnie
<?php include "log/login.php' ?>
ptem wciskam rejestracja ktOra ma link taki
index.php?menu=rejestracja
i wtedy wyskakuje ten łą co podałem wyżej !
TomASS
Prawdopodobnie gdzieś masz zdublowaną klasę. Co masz w pliku
./DbSql.inc.php ?
mefjiu
pliczek DbSql.inc.php

  1. <?php
  2.  
  3. include("const.inc.php");
  4.  
  5. Class DBSQL
  6. {
  7.      
  8.    function DBSQL($DBName)
  9.    {     
  10.       global $DBHost,$DBUser,$DBPassword;
  11.       $conn=mysql_connect($DBHost,$DBUser,$DBPassword);
  12.       mysql_select_db($DBName,$conn); 
  13.       $this->CONN = $conn;
  14.       return true;
  15.    }
  16.    
  17.    function select($sql="")
  18.    {
  19.       if (empty($sql)) return false;
  20.       if (empty($this->CONN)) return false;
  21.       $conn = $this->CONN;
  22.       $results = mysql_query($sql,$conn);
  23.       if ((!$results) or (empty($results)))
  24.       {       
  25.          return false;
  26.       }
  27.       $count = 0;
  28.       $data = array();
  29.       while ($row = mysql_fetch_array($results)) {
  30.          $data[$count] = $row;
  31.          $count++;
  32.       }
  33.       mysql_free_result($results);
  34.       return $data;
  35.    }
  36.  
  37.    
  38.    function insert($sql="")
  39.    {
  40.       if (empty($sql)) return false;
  41.       if (empty($this->CONN)) return false;
  42.  
  43.       $conn = $this->CONN;
  44.       $results = mysql_query($sql,$conn);
  45.       if (!$results) return false;
  46.       $results = mysql_insert_id();
  47.       return $results;
  48.    }
  49.  
  50.    
  51.    function update($sql="")
  52.    {
  53.       if(empty($sql)) return false;
  54.       if(empty($this->CONN)) return false;
  55.  
  56.       $conn = $this->CONN;
  57.       $result = mysql_query($sql,$conn);
  58.       return $result;
  59.    }
  60.  
  61.    
  62.    function delete($sql="")
  63.    {
  64.       if(empty($sql)) return false;
  65.       if(empty($this->CONN)) return false;
  66.  
  67.       $conn = $this->CONN;
  68.       $result = mysql_query($sql,$conn);
  69.       return $result;
  70.    }
  71.    
  72.    function createtable($sql="")
  73.    {
  74.       if(empty($sql)) return false;
  75.       if(empty($this->CONN)) return false;
  76.  
  77.       $conn = $this->CONN;
  78.       $result = mysql_query($sql,$conn);
  79.       return $result;
  80.    }
  81.    
  82.    function droptable($sql="")
  83.    {
  84.       if(empty($sql)) return false;
  85.       if(empty($this->CONN)) return false;
  86.  
  87.       $conn = $this->CONN;
  88.       $result = mysql_query($sql,$conn);
  89.       return $result;
  90.    }
  91.    
  92.    function createindex($sql="")
  93.    {
  94.       if(empty($sql)) return false;
  95.       if(empty($this->CONN)) return false;
  96.  
  97.       $conn = $this->CONN;
  98.       $result = mysql_query($sql,$conn);
  99.       return $result;
  100.    }
  101.    
  102.    function dropindex($sql="")
  103.    {
  104.       if(empty($sql)) return false;
  105.       if(empty($this->CONN)) return false;
  106.  
  107.       $conn = $this->CONN;
  108.       $result = mysql_query($sql,$conn);
  109.       return $result;
  110.    }
  111.  
  112. }
  113.  
  114. ?>
piku
Oznacza to że dwa razy includujesz klasę CustomSQL lub dwa razy definiujesz zmienne
np
  1. <?php
  2. $t = new CustomSQL
  3. ?>

czy jak tam to masz zrobione.
dr_bonzo
1. Dwukrotnie deklarujesz klase CustomSQL
- posprawdzaj jakie pliki sie includuja (np. uzyj require_once)
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.