27. december 2003 - 00:43
Der er
3 kommentarer og 2 løsninger
Fejl i nyhedsscript
Hej, jeg har lidt problemer med et nyhedsscript i php, dog er der en fejl som jeg ikke helt kan fixe, og den er på linie 65 og lyder på: Parse error: parse error in C:\Server\html\web\amplificator\nyheder.php on line 65 På forhånd tak. _______________________________________ <? $pass = ("123456"); //Passwordet for at tilføje nyheder ?> <? if (!$action || $action == "vis") { ?> <html> <head> <title>AmpNews // Nyhed</title> <style> A:link {color: #999999; text-decoration: none; font-family: Tahoma; font-size: 12px;} A:visited {color: #999999; text-decoration: none; font-family: Tahoma; font-size: 12px;} A:hover {color: #999999; text-decoration: none; font-family: Tahoma; font-size: 12px;} A:active {color: #999999; text-decoration: none; font-family: Tahoma; font-size: 12px;} p {color: #000000; text-decoration: none; font-family: Tahoma; font-size: 12px;} </style> </head> <body bgcolor="#FFFFFF"> <div align="center"> <center> <table border="0" cellspacing="0" width="500" bordercolor="#000000" border-style="solid"> <tr> <td width="500"> <h1 align="center">AmpNews</h1> <div align="center"> <center> <table border="0" cellspacing="0" width="500" bordercolor="#000000" border-style="solid"> <tr> <td width="500" bgcolor="#FFFFFF"> <? readfile("nyheder.txt") ?></td> </tr> </table> </center> </div> </td> </tr> </table> </center> </div> <center><a href="?action=tilfoj">Tilføj nyhed</a></center> </body> </html> <? } elseif ($action == "tilfoj") { ?> <? $dato = date("d/m Y", time()); if($password == "$pass" && $nyhed) { $file = "nyheder.txt"; $nyhed = strip_tags("$nyhed", "<br>"); $nyhed = ereg_replace("\n", "<br>", $nyhed); $str = " <font size=1 face=verdana color="#000000"><b><i>Dato:</b> $dato</i></b></font><br> <font size=2 face=verdana color="#000000"> $nyhed</font><br> <hr color=#000000> "; $fp = fopen($file, "r"); $arr = file($file); $res = implode( "", $arr); $res = "$str$res"; fclose($fp); $fp = fopen($file, "w"); fputs($fp, $res); fclose($fp); header("location: $PHP_SELF"); } ?> <html> <head> <title>AmpNews // Tilføj</title> <style> A:link {color: #999999; text-decoration: none; font-family: Tahoma; font-size: 12px;} A:visited {color: #999999; text-decoration: none; font-family: Tahoma; font-size: 12px;} A:hover {color: #999999; text-decoration: none; font-family: Tahoma; font-size: 12px;} A:active {color: #999999; text-decoration: none; font-family: Tahoma; font-size: 12px;} p {color: #000000; text-decoration: none; font-family: Tahoma; font-size: 12px;} </style> </head> <body bgcolor="#FFFFFF"> <div align="center"> <center> <table border="0" cellspacing="0" width="500" border-style="solid"> <tr> <td width="500"> <h1 align="center">AmpNews</h1> <div align="center"> <center> <table border="0" cellspacing="0" width="500" bordercolor="#000000" border-style="solid"> <tr> <td width="500" bgcolor="#FFFFFF"> <div align="center"> <center> <table border="0" cellspacing="0" width="85%" cellpadding="0" border-style="solid"> <tr> <td width="100%"><br><p><b>Tilføj nyhed:</b></p></font> <form action="<? $PHP_SELF ?>?action=tilfoj" method="post"> <p>Kodeord:<br> <input type="password" name="password" size="15"><br></p> <p>Nyhed:<br> <textarea rows="5" name="nyhed" cols="25"></textarea><br> <input type="submit" value="OK"></p> </form> </td> </tr> </table> </center> </div> </td> </tr> </table> </center> </div> </td> </tr> </table> </center> </div> <center><a href="java script:history.back();">Tilbage</a></center> </body> </html> <? } else { ?> <html> <head> <title>Fejl...</title> </head> <body> <h1>Fejl...</h1> <a href="java script:history.back();">Tilbage</a> </body> </html> <? } ?> _______________________________________
Annonceindlæg fra Computerworld it-jobbank
27. december 2003 - 00:45
#1
<? $pass = ("123456"); //Passwordet for at tilføje nyheder ?> <? if (!$action || $action == "vis") { ?> <html> <head> <title>AmpNews // Nyhed</title> <style> A:link {color: #999999; text-decoration: none; font-family: Tahoma; font-size: 12px;} A:visited {color: #999999; text-decoration: none; font-family: Tahoma; font-size: 12px;} A:hover {color: #999999; text-decoration: none; font-family: Tahoma; font-size: 12px;} A:active {color: #999999; text-decoration: none; font-family: Tahoma; font-size: 12px;} p {color: #000000; text-decoration: none; font-family: Tahoma; font-size: 12px;} </style> </head> <body bgcolor="#FFFFFF"> <div align="center"> <center> <table border="0" cellspacing="0" width="500" bordercolor="#000000" border-style="solid"> <tr> <td width="500"> <h1 align="center">AmpNews</h1> <div align="center"> <center> <table border="0" cellspacing="0" width="500" bordercolor="#000000" border-style="solid"> <tr> <td width="500" bgcolor="#FFFFFF"> <? readfile("nyheder.txt") ?></td> </tr> </table> </center> </div> </td> </tr> </table> </center> </div> <center><a href="?action=tilfoj">Tilføj nyhed</a></center> </body> </html> <? } elseif ($action == "tilfoj") { ?> <? $dato = date("d/m Y", time()); if($password == "$pass" && $nyhed) { $file = "nyheder.txt"; $nyhed = strip_tags("$nyhed", "<br>"); $nyhed = ereg_replace("\n", "<br>", $nyhed); $str = " <font size=1 face=verdana color='#000000'><b><i>Dato:</b> $dato</i></b></font><br> <font size=2 face=verdana color='#000000'> $nyhed</font><br> <hr color=#000000> "; $fp = fopen($file, "r"); $arr = file($file); $res = implode( "", $arr); $res = "$str$res"; fclose($fp); $fp = fopen($file, "w"); fputs($fp, $res); fclose($fp); header("location: $PHP_SELF"); } ?> <html> <head> <title>AmpNews // Tilføj</title> <style> A:link {color: #999999; text-decoration: none; font-family: Tahoma; font-size: 12px;} A:visited {color: #999999; text-decoration: none; font-family: Tahoma; font-size: 12px;} A:hover {color: #999999; text-decoration: none; font-family: Tahoma; font-size: 12px;} A:active {color: #999999; text-decoration: none; font-family: Tahoma; font-size: 12px;} p {color: #000000; text-decoration: none; font-family: Tahoma; font-size: 12px;} </style> </head> <body bgcolor="#FFFFFF"> <div align="center"> <center> <table border="0" cellspacing="0" width="500" border-style="solid"> <tr> <td width="500"> <h1 align="center">AmpNews</h1> <div align="center"> <center> <table border="0" cellspacing="0" width="500" bordercolor="#000000" border-style="solid"> <tr> <td width="500" bgcolor="#FFFFFF"> <div align="center"> <center> <table border="0" cellspacing="0" width="85%" cellpadding="0" border-style="solid"> <tr> <td width="100%"><br><p><b>Tilføj nyhed:</b></p></font> <form action="<? $PHP_SELF ?>?action=tilfoj" method="post"> <p>Kodeord:<br> <input type="password" name="password" size="15"><br></p> <p>Nyhed:<br> <textarea rows="5" name="nyhed" cols="25"></textarea><br> <input type="submit" value="OK"></p> </form> </td> </tr> </table> </center> </div> </td> </tr> </table> </center> </div> </td> </tr> </table> </center> </div> <center><a href="java script:history.back();">Tilbage</a></center> </body> </html> <? } else { ?> <html> <head> <title>Fejl...</title> </head> <body> <h1>Fejl...</h1> <a href="java script:history.back();">Tilbage</a> </body> </html> <? } ?>
27. december 2003 - 00:45
#2
Du brugte " under en echo, dette har jeg rettet så tagget bruger ' istedet.
27. december 2003 - 00:48
#3
Enten laver du det sådan: $str = ' <font size=1 face=verdana color="#000000"><b><i>Dato:</b> '.$dato.'</i></b></font><br> <font size=2 face=verdana color="#000000"> '.$nyhed.'</font><br> <hr color=#000000> '; Eller sådan: $str = " <font size=1 face=verdana color=\"#000000\"><b><i>Dato:</b> $dato</i></b></font><br> <font size=2 face=verdana color=\"#000000\"> $nyhed</font><br> <hr color=#000000> ";
27. december 2003 - 00:50
#4
Ahv: Dit virkede! Tak for det :) Jeg giver lige sub-zero et par point fordi han prøvede (men hans svar virkede ikke)
Slettet bruger
27. december 2003 - 07:53
#5
Men lyt efter sub_zeros råd alligevel, for det er godt nok.
Vi tilbyder markedets bedste kurser inden for webudvikling