Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem fetch_users()
Marecki669
post 2.06.2012, 16:49:22
Post #1





Grupa: Zarejestrowani
Postów: 45
Pomógł: 0
Dołączył: 2.06.2012
Skąd: Jarocin

Ostrzeżenie: (0%)
-----


Witam,
Mam problem otóż gdy chcę wyświetlić listę użytkowników wyskakuje błąd:


SCREAM: Error suppression ignored for
Fatal error: Cannot redeclare dbConnect() (previously declared in C:\wamp\www\include\funkcje.php:13) in C:\wamp\www\include\funkcje.php on line 27


Plik user_list.php
  1. <?php
  2.  
  3. include('include/funkcje.php');
  4. include('include/funkcje.profiles.php');
  5.  
  6. ?>
  7.  
  8. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  9. <html xmlns="http://www.w3.org/1999/xhtml">
  10. <head>
  11. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  12. <title>Untitled Document</title>
  13. </head>
  14.  
  15. <body>
  16. <?php
  17.  
  18. foreach (fetch_users() as $user){
  19. ?>
  20. <p>
  21. <a href=""><?php echo $user['name']; ?></a>
  22. </p>
  23. <?php
  24.  
  25. }
  26.  
  27. ?>


Plik funkcje.php
  1. <?php
  2.  
  3. // Funkcja łączenia z bazą danych
  4. function dbConnect(){
  5. $con = mysql_pconnect("localhost","root","");
  6. if(!$con){
  7. return false;
  8. }
  9.  
  10. if(!mysql_select_db("test")){
  11. return false;
  12. }
  13.  
  14. return $con;
  15.  
  16. }
  17. ?>




plik funkcje.user.profiles.php:
  1. <?php
  2.  
  3. function fetch_users(){
  4. $result = mysql_query("SELECT 'user_id' AS 'id', 'user_name' AS 'name' FROM 'users'");
  5.  
  6. $users = array();
  7.  
  8. while (($row = mysql_fetch_assoc($result)) !== false){
  9. $users[] = $row;
  10. }
  11.  
  12. return $users;
  13. }
  14.  
  15.  
  16. ?>




plik funkcje.profiles:
  1. <?php
  2.  
  3. include('funkcje.user.profiles.php');
  4.  
  5. $_SESSION['uid'] = 1;
  6.  
  7. ?>


Proszę o pomoc!

Ten post edytował Marecki669 2.06.2012, 16:50:30
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
d3ut3r
post 2.06.2012, 17:02:06
Post #2





Grupa: Zarejestrowani
Postów: 709
Pomógł: 176
Dołączył: 24.10.2010

Ostrzeżenie: (0%)
-----


php dokładnie Ci napisało co jest nie tak, masz 2 razy zadeklarowaną funkcję dbConnect (ogólnie nie możesz mieć dwóch funkcji o tej samej nazwie). Spójrz na plik w liniach o których mowa w komunikacie błędu.


--------------------
http://d3ut3r.wordpress.com/ | mysql_* jest przestarzałe UŻYWAJ PDO!
Go to the top of the page
+Quote Post
Marecki669
post 2.06.2012, 17:27:03
Post #3





Grupa: Zarejestrowani
Postów: 45
Pomógł: 0
Dołączył: 2.06.2012
Skąd: Jarocin

Ostrzeżenie: (0%)
-----


Dziękuję, Pomogło smile.gif

Mam jeszcze jeden problem napisany prosił bym o wejrzenie Temat: ERROR mysql num rows POMOCY
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 19.07.2025 - 11:45