fatter nada...

Tags:    php

Hey jeg har lavet et lille download system, men får denne fejl når jeg klikker download:

Warning: Cannot modify header information - headers already sent by (output started at /customers/woox.dk/woox.dk/httpd.www/download/index.php:3) in /customers/woox.dk/woox.dk/httpd.www/download/index.php on line 49


Hele koden er:

1. <html>
2. <head>
3. <STYLE type=text/css>BODY {
4. scrollbar-arrow-color: #444444;
5. scrollbar-track-color: #f7f7f7;
6. scrollbar-face-color: #f7f7f7;
7. scrollbar-shadow-color: #f7f7f7;
8. scrollbar-highlight-color: #f7f7f7;
9. scrollbar-darkshadow-color: #f7f7f7;
10. scrollbar-3dlight-color: #f7f7f7;
11. }
12. </STYLE>
13. <STYLE type=text/css>A:link {
14. TEXT-DECORATION: underline
15. }
16. A:active {
17. TEXT-DECORATION: underline
18. }
19. A:visited {
20. TEXT-DECORATION: underline
21. }
22. A:hover {
23. TEXT-DECORATION: underline
24. }
25. </STYLE>
26.
27. <STYLE fprolloverstyle>A:hover {font-family: Verdana; text-decoration: none}
28. </STYLE>
29. <title></title>
30. </head>
31.
32. <body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" text="#444444" link="#444444" vlink="#444444" alink="#444444" bgcolor="#F7F7F7">
33.
34. <p align="center"><font size="1" face="Verdana">PHP sektion:</font></p>
35.
36. <p><font size="1" face="Verdana">Her kan du downloade PHP systemer og
37. selvfølgelig kan alle tilføje systemer.</font></p>
38. <?
39. $woox['mysql']['host'] = 'localhost';
40. $woox['mysql']['username'] = '******';
41. $woox['mysql']['password'] = '******';
42. $woox['mysql']['database'] = '******';
43.
44. mysql_connect($woox['mysql']['host'],$woox['mysql']['username'],$woox['mysql']['password']);
45. mysql_select_db($woox['mysql']['database']);
46. if ($_GET["file"]){
47. mysql_query("UPDATE download SET hits = hits+1 WHERE url = '$_GET[file]'");
48. header("location: $_GET[file]");
49. } else {
50. $query = mysql_query("SELECT * FROM download");
51. while ($row = mysql_fetch_array($query)) {
52.
53. echo "<p><font face=\\"verdana\\" size=\\"1\\"><b><a href=\\"?file=$row[url]\\">$row[navn]</a>:</b><br>$row[text]<br> - Downloads: <b>$row[hits]</b></font></p>";
54. }
55. }
56. ?>



4 svar postet i denne tråd vises herunder
1 indlæg har modtaget i alt 4 karma
Sorter efter stemmer Sorter efter dato
Hey jeg har lavet et lille download system, men får denne fejl når jeg klikker download:

Warning: Cannot modify header information - headers already sent by (output started at /customers/woox.dk/woox.dk/httpd.www/download/index.php:3) in /customers/woox.dk/woox.dk/httpd.www/download/index.php on line 49


Hele koden er:

1. <html>
2. <head>
3. <STYLE type=text/css>BODY {
4. scrollbar-arrow-color: #444444;
5. scrollbar-track-color: #f7f7f7;
6. scrollbar-face-color: #f7f7f7;
7. scrollbar-shadow-color: #f7f7f7;
8. scrollbar-highlight-color: #f7f7f7;
9. scrollbar-darkshadow-color: #f7f7f7;
10. scrollbar-3dlight-color: #f7f7f7;
11. }
12. </STYLE>
13. <STYLE type=text/css>A:link {
14. TEXT-DECORATION: underline
15. }
16. A:active {
17. TEXT-DECORATION: underline
18. }
19. A:visited {
20. TEXT-DECORATION: underline
21. }
22. A:hover {
23. TEXT-DECORATION: underline
24. }
25. </STYLE>
26.
27. <STYLE fprolloverstyle>A:hover {font-family: Verdana; text-decoration: none}
28. </STYLE>
29. <title></title>
30. </head>
31.
32. <body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" text="#444444" link="#444444" vlink="#444444" alink="#444444" bgcolor="#F7F7F7">
33.
34. <p align="center"><font size="1" face="Verdana">PHP sektion:</font></p>
35.
36. <p><font size="1" face="Verdana">Her kan du downloade PHP systemer og
37. selvfølgelig kan alle tilføje systemer.</font></p>
38. <?
39. $woox['mysql']['host'] = 'localhost';
40. $woox['mysql']['username'] = '******';
41. $woox['mysql']['password'] = '******';
42. $woox['mysql']['database'] = '******';
43.
44. mysql_connect($woox['mysql']['host'],$woox['mysql']['username'],$woox['mysql']['password']);
45. mysql_select_db($woox['mysql']['database']);
46. if ($_GET["file"]){
47. mysql_query("UPDATE download SET hits = hits+1 WHERE url = '$_GET[file]'");
48. header("location: $_GET[file]");
49. } else {
50. $query = mysql_query("SELECT * FROM download");
51. while ($row = mysql_fetch_array($query)) {
52.
53. echo "<p><font face=\\"verdana\\" size=\\"1\\"><a href=\\"?file=$row[url]\\">$row[navn]</a>:$row[text] - Downloads: $row[hits]</font></p>";
54. }
55. }
56. ?>

Det er fordi du har header("location: $_GET[file]"); i linje 48. header kan kun bruges hvis du ikke har sendt noget data til clienten. dvs. at du skal bruge header før du udskriver noget HTML / CSS / osv..

- SpeC - #SpeC.DK @ Q-NET



Forstår ikke helt, men hvis jeg lige skriver hele koden uden tal, vil du så ikke lave det?

HELE KODEN:

<html>
<head>
<STYLE type=text/css>BODY {
scrollbar-arrow-color: #444444;
scrollbar-track-color: #f7f7f7;
scrollbar-face-color: #f7f7f7;
scrollbar-shadow-color: #f7f7f7;
scrollbar-highlight-color: #f7f7f7;
scrollbar-darkshadow-color: #f7f7f7;
scrollbar-3dlight-color: #f7f7f7;
}
</STYLE>
<STYLE type=text/css>A:link {
TEXT-DECORATION: underline
}
A:active {
TEXT-DECORATION: underline
}
A:visited {
TEXT-DECORATION: underline
}
A:hover {
TEXT-DECORATION: underline
}
</STYLE>

<STYLE fprolloverstyle>A:hover {font-family: Verdana; text-decoration: none}
</STYLE>
<title></title>
</head>

<body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" text="#444444" link="#444444" vlink="#444444" alink="#444444" bgcolor="#F7F7F7">

<p align="center"><font size="1" face="Verdana">PHP sektion:</font></p>

<p><font size="1" face="Verdana">Her kan du downloade PHP systemer og
selvfølgelig kan alle tilføje systemer.</font></p>
<?
$woox['mysql']['host'] = 'localhost';
$woox['mysql']['username'] = '******';
$woox['mysql']['password'] = '******';
$woox['mysql']['database'] = '******';

mysql_connect($woox['mysql']['host'],$woox['mysql']['username'],$woox['mysql']['password']);
mysql_select_db($woox['mysql']['database']);
if ($_GET["file"]){
mysql_query("UPDATE download SET hits = hits+1 WHERE url = '$_GET[file]'");
header("location: $_GET[file]");
} else {
$query = mysql_query("SELECT * FROM download");
while ($row = mysql_fetch_array($query)) {

echo "<p><font face=\\"verdana\\" size=\\"1\\"><b><a href=\\"?file=$row[url]\\">$row[navn]</a>:</b><br>$row[text]<br> - Downloads: <b>$row[hits]</b></font></p>";
}
}
?>



<pre>
<html>
<head>
<STYLE type=text/css>BODY {
scrollbar-arrow-color: #444444;
scrollbar-track-color: #f7f7f7;
scrollbar-face-color: #f7f7f7;
scrollbar-shadow-color: #f7f7f7;
scrollbar-highlight-color: #f7f7f7;
scrollbar-darkshadow-color: #f7f7f7;
scrollbar-3dlight-color: #f7f7f7;
}
</STYLE>
<STYLE type=text/css>A:link {
TEXT-DECORATION: underline
}
A:active {
TEXT-DECORATION: underline
}
A:visited {
TEXT-DECORATION: underline
}
A:hover {
TEXT-DECORATION: underline
}
</STYLE>

<STYLE fprolloverstyle>A:hover {font-family: Verdana; text-decoration: none}
</STYLE>
<title></title>
</head>

<body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" text="#444444" link="#444444" vlink="#444444" alink="#444444" bgcolor="#F7F7F7">

<p align="center"><font size="1" face="Verdana">PHP sektion:</font></p>

<p><font size="1" face="Verdana">Her kan du downloade PHP systemer og
selvfølgelig kan alle tilføje systemer.</font></p>
<?
$woox['mysql']['host'] = 'localhost';
$woox['mysql']['username'] = '******';
$woox['mysql']['password'] = '******';
$woox['mysql']['database'] = '******';

mysql_connect($woox['mysql']['host'],$woox['mysql']['username'],$woox['mysql']['password']);
mysql_select_db($woox['mysql']['database']);
if ($_GET["file"]){
mysql_query("UPDATE download SET hits = hits+1 WHERE url = '$_GET[file]'");
// HER HAR JEG BRUGE HTML I STEDET FOR PHP - START
$host = $_SERVER['HTTP_HOST'];
$file = $_GET[file];
echo "<meta http-equiv=\\"Refresh\\"
content=\\"5;URL=http://$file\\">
// STOP
} else {
$query = mysql_query("SELECT * FROM download");
while ($row = mysql_fetch_array($query)) {

echo "<p><font face=\\"verdana\\" size=\\"1\\"><a href=\\"?file=$row[url]\\">$row[navn]</a>:$row[text] - Downloads: $row[hits]</font></p>";
}
}
?>
</pre>
Prøv denne kode hvis den ikke virker så skriv lige....

- SpeC - #SpeC.DK @ Q-NET



Sådan det virkede :D brugte den her: http://download.woox.dk/



t