Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> headers already sent - pierwszy problem ze skryptem, drugi - czemu nie chce wyciagnac pliku z bazy ;/
andy84
post 17.03.2007, 13:37:07
Post #1





Grupa: Zarejestrowani
Postów: 165
Pomógł: 0
Dołączył: 14.11.2005
Skąd: London

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


Zrobilem formularz z uploadem cv jednak po odpaleniu informacji wyswietlanych dostaje takie komunikaty bledu:

Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\prolinc\project\admin\header.php:7) in C:\AppServ\www\prolinc\project\admin\regusers\fulldetails.php on line 13

Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\prolinc\project\admin\header.php:7) in C:\AppServ\www\prolinc\project\admin\regusers\fulldetails.php on line 14

Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\prolinc\project\admin\header.php:7) in C:\AppServ\www\prolinc\project\admin\regusers\fulldetails.php on line 15

a tutaj jest kod
  1. <?php
  2. include ("../header.php");
  3. include ("../config.inc.php");
  4.  
  5. mysql_connect($host,$user,$password);
  6. @mysql_select_db($database) or die ("Unable to select database");
  7.  
  8. if(isset($_GET['id']))
  9. $id = $_GET['id']; 
  10. $query="SELECT * FROM registry WHERE id='$id'";
  11. $result = mysql_query($query) or die('Error, query failed'); 
  12. list($name, $type, $size, $content) = mysql_fetch_array($result); 
  13. header("Content-Disposition: attachment; filename=$name"); 
  14. header("Content-length: $size"); 
  15. header("Content-type: $type"); 
  16. $num=mysql_num_rows($result);
  17. $i=0;
  18. while($i < $num){
  19.  
  20. $id=mysql_result($result,$i,"id");
  21. $firstname=mysql_result($result,$i,"firstname");
  22. $surname=mysql_result($result,$i,"surname");
  23. $address1=mysql_result($result,$i,"address1");
  24. $address2=mysql_result($result,$i,"address2");
  25. $postcode=mysql_result($result,$i,"postcode");
  26. $towncity=mysql_result($result,$i,"towncity");
  27. $email=mysql_result($result,$i,"email");
  28. $mobile=mysql_result($result,$i,"mobile");
  29. $string=mysql_result($result,$i,"string");
  30. $experience=mysql_result($result,$i,"experience");
  31. $addinfo=mysql_result($result,$i,"addinfo");
  32. $day=mysql_result($result,$i,"day");
  33. $mth=mysql_result($result,$i,"mth");
  34. $year=mysql_result($result,$i,"year");
  35. ?>


reszta kodu tego samego pliku
  1. <? 
  2. #include 'library/config.php'; 
  3. #include 'library/opendb.php'; 
  4.  
  5. $query = "SELECT id, name FROM registry"; 
  6. $result = mysql_query($query) or die('Error, query failed'); 
  7. if(mysql_num_rows($result) == 0) 
  8. { 
  9. echo "Database is empty <br>"; 
  10. }
  11. else 
  12. { 
  13. while(list($id, $name) = mysql_fetch_array($result)) 
  14. { 
  15. ?> 
  16. <a href="fulldetails.php?id=<?=$id;?>"><?=$name;?></a> <br> 
  17. <?  
  18. } 
  19. } 
  20. #include 'library/closedb.php'; 
  21. ?> 
  22. </td>
  23. </tr>
  24. </table>
  25. <p><hr></p></td>
  26. <td> </td> 
  27. </tr>
  28. <tr>
  29. <td> </td>
  30. <td> </td>
  31. <td> </td>
  32. </tr>
  33. </table></td>
  34. </tr>
  35. </table>
  36. <?php
  37. $i++;
  38.  exit; 
  39. }
  40. include('../../footer.php');
  41. ?>


Moze ktos z wiekszym doswiadczeniem powie mi gdzie tu jest blad ;/ bo ja go nie moge zrozumiec


--------------------
Linux is like Wigwam - no Windows, no Gates and apache inside :D
Go to the top of the page
+Quote Post
Jarod
post 17.03.2007, 13:43:06
Post #2





Grupa: Zarejestrowani
Postów: 1 190
Pomógł: 27
Dołączył: 23.04.2005

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


1. Nie ten dział.
2. http://pl2.php.net/manual/pl/function.ob-start.php


--------------------
”Godzina nauki w życiu nowoczesnego apostoła jest godziną modlitwy.”
(św. Josemaría Escrivá, Droga, 335)
Go to the top of the page
+Quote Post
andy84
post 17.03.2007, 15:45:48
Post #3





Grupa: Zarejestrowani
Postów: 165
Pomógł: 0
Dołączył: 14.11.2005
Skąd: London

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


Cytat(J4r0d @ 17.03.2007, 12:43:06 ) *

Moze i jestem tepy ale
1 skoro zly dzial to moze napisz gdzie to wypisac ja widze problem z moim php
2. po co mi ob-start mi z jakiegos powodu nie chce sciagac pliku z mysql a wina jest kodu poniewaz tu jest kod ktory sciaga pliki z mysql i jego modyfikowalem wlasnie do tego skryptu wyzej , to dziala bez ob-start moze takto mi wyjasnij po co mi on w tym przypadku - pozdrawiam
  1. <? 
  2. if(isset($_GET['id'])) 
  3. { 
  4.  # include 'library/config.php'; 
  5.  # include 'library/opendb.php'; 
  6.  
  7. $id = $_GET['id']; 
  8. $query  = "SELECT name, type, size, content FROM upload WHERE id = '$id'"; 
  9. $result = mysql_query($query) or die('Error, query failed'); 
  10. list($name, $type, $size, $content) = mysql_fetch_array($result); 
  11.  
  12. header("Content-Disposition: attachment; filename=$name"); 
  13. header("Content-length: $size"); 
  14. header("Content-type: $type"); 
  15. echo $content; 
  16.  
  17.  # include 'library/closedb.php';  
  18. exit; 
  19. } 
  20.  
  21. ?> 
  22.  
  23. <? 
  24. #include 'library/config.php'; 
  25. #include 'library/opendb.php'; 
  26.  
  27. $query = "SELECT id, name FROM registry"; 
  28. $result = mysql_query($query) or die('Error, query failed'); 
  29. if(mysql_num_rows($result) == 0) 
  30. { 
  31. echo "Database is empty <br>"; 
  32. }
  33. else 
  34. { 
  35. while(list($id, $name) = mysql_fetch_array($result)) 
  36. { 
  37. ?> 
  38. <a href="download.php?id=<?=$id;?>"><?=$name;?></a> <br> 
  39. <?  
  40. } 
  41. } 
  42. #include 'library/closedb.php'; 
  43. ?>


--------------------
Linux is like Wigwam - no Windows, no Gates and apache inside :D
Go to the top of the page
+Quote Post
bne
post 17.03.2007, 16:28:23
Post #4





Grupa: Zarejestrowani
Postów: 83
Pomógł: 1
Dołączył: 18.10.2006

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


"headers already sent",

to znaczy, że nagłówki zostały już wysłane...nagłówki muszą być wysłane przed jakąkolwiek zawartością strony...


--------------------
Darmowa wyszukiwarka MP3
Go to the top of the page
+Quote Post
andy84
post 17.03.2007, 17:59:37
Post #5





Grupa: Zarejestrowani
Postów: 165
Pomógł: 0
Dołączył: 14.11.2005
Skąd: London

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


Cytat(bne @ 17.03.2007, 15:28:23 ) *
"headers already sent",

to znaczy, że nagłówki zostały już wysłane...nagłówki muszą być wysłane przed jakąkolwiek zawartością strony...


Dzieki smile.gif tego wlasnie brakowalo nie rozumialem czemu zostalo juz wyslane skoro wysylam pierwszy raz a to dlatego ze cos juz bylo przed nimi smile.gif pozdro smiga co potrzeboowalem


--------------------
Linux is like Wigwam - no Windows, no Gates and apache inside :D
Go to the top of the page
+Quote Post
pr0kt0r
post 17.03.2007, 18:25:54
Post #6





Grupa: Zarejestrowani
Postów: 35
Pomógł: 1
Dołączył: 1.12.2006

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


Możesz się przed takim komunikatem zabezpieczyć używając headers_sent" title="Zobacz w manualu PHP" target="_manual
Go to the top of the page
+Quote Post
Jarod
post 17.03.2007, 20:01:49
Post #7





Grupa: Zarejestrowani
Postów: 1 190
Pomógł: 27
Dołączył: 23.04.2005

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


Cytat(andy84 @ 17.03.2007, 15:45:48 ) *
Moze i jestem tepy ale
1 skoro zly dzial to moze napisz gdzie to wypisac ja widze problem z moim php
2. po co mi ob-start mi z jakiegos powodu nie chce sciagac pliku z mysql a wina jest kodu poniewaz tu jest kod ktory sciaga pliki z mysql i jego modyfikowalem wlasnie do tego skryptu wyzej , to dziala bez ob-start moze takto mi wyjasnij po co mi on w tym przypadku - pozdrawiam

1. przeczytaj regulamin
2. jakbyś przeczytał to co w linku podałem to wiedziałbyś po co się stosuje ob_start.


--------------------
”Godzina nauki w życiu nowoczesnego apostoła jest godziną modlitwy.”
(św. Josemaría Escrivá, Droga, 335)
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: 31.07.2025 - 06:18