cloevvold Posted October 30, 2007 Share Posted October 30, 2007 I have a script that dosent show Special Characters (æøå) properly. It is a news system. The strange thing is that it works in the newstext, but not on the headline. I hope someone can help me here? This is the scripts: The index page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <meta name="generator" content="Adobe GoLive" /> <title>Noram Produkter A/S - Ventilasjon På Naturens Vilkår</title> <link rel="stylesheet" href="../css/lightbox.css" type="text/css" media="screen" /> <script src="../js/prototype.js" type="text/javascript"></script> <script src="../js/scriptaculous.js?load=effects" type="text/javascript"></script> <script src="./js/lightbox.js" type="text/javascript"></script> <style type="text/css"> #lightbox, #overlay { z-index:10000 !important; } </style> <link href="../css/style.css" rel="stylesheet" type="text/css" media="all" /> </head> <body> <!-- ImageReady Slices (1_home.psd - Slices: 01, 03) --> <table width="759" border="0" cellpadding="0" cellspacing="0" align="center"> <tr> <td width="759" height="566" ALT="" valign="top" bgcolor="#FFFFFF"> <table width="759" border="0" cellpadding="0" cellspacing="0"> <tr> <td bgcolor="white" width="271" height="566" valign="top" alt="" style="background-position:bottom; background-repeat:no-repeat " background="../bilder/hoved_design/buisness.jpg"> <div align="left"> <img src="../bilder/hoved_design/logo.jpg" alt="" height="69" width="271" usemap="#logo16be78b" border="0" /><map name="logo16be78b"><area shape="rect" coords="27,14,243,58" href="../index.html" alt="" /></map></div> </td> <td width="488" height="566" alt="" valign="top" style="background-position:top right; background-repeat:no-repeat " background="../bilder/hoved_design/girl.jpg"> <table width="488" border="0" cellpadding="0" cellspacing="0"> <tr> <td colspan="5"> <menumachine name="mainmenu" id="m17wmfhu"> <csobj t="Component" csref="../menumachine/mainmenu/menuspecs.menudata"><noscript> <p><a class="mm_no_js_link" href="../menumachine/mainmenu/navigation.html">Site Navigation</a></p> </noscript> </csobj> <script type="text/javascript"><!-- var mmfolder=/*URL*/"../menumachine/",zidx=1000; //--></script> <script type="text/javascript" src="../menumachine/menumachine2.js"></script> <script type="text/javascript" src="../menumachine/mainmenu/menuspecs.js"></script> </menumachine> </td> </tr> </table> <div style="margin-left:31px; margin-top:24px; width:340px "> <br /> <br /> <img src="../bilder/hoved_design/ventilasjon.jpg" alt="" width="232" height="20" border="0" /><br /> <br /> </div> <div style="margin-top:20px "> <table width="486" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF"> <tr> <td background="../bilder/hoved_design/red_td.jpg" width="486" height="33" ALT="" valign="top"> <div style="margin-top:1px "> <table width="486" height="32" border="0" cellspacing="0" cellpadding="0"> <tr> <td style="background-position:right; background-repeat:repeat-y " colspan="2" valign="top" width="486"> <div style="margin-left:29px; margin-top:12px "> <span class="bot_men"><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Nyheter </font></b> <a href="admin.php">Legg til nyhet</a></span></div> </td> </tr> </table> </div> </td> </tr> <tr> <td width="486" height="312" ALT="" valign="top"> <table width="486" height="407" border="0" cellspacing="0" cellpadding="0" background="../bilder/hoved_design/px1.jpg" style="background-position:right; background-repeat:repeat-y "> <tr> <td class="box" height="407" valign="top" background="../bilder/hoved_design/px1.jpg" style="background-position:left; background-repeat:repeat-y "> <div style="margin-top:5px "> <div class="box"><?php // This function reads all available news function getNewsList(){ $fileList = array(); // Open the actual directory if ($handle = opendir("news")) { // Read all file from the actual directory while ($file = readdir($handle)) { if (!is_dir($file)) { $fileList[] = $file; } } } rsort($fileList); return $fileList; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html> <head> <link href="style/style.css" rel="stylesheet" type="text/css" /> </head> <body> <table width="100%"> <?php $list = getNewsList(); foreach ($list as $value) { $newsData = file("news/".$value); $newsTitle = $newsData[0]; $submitDate = $newsData[1]; unset ($newsData['0']); unset ($newsData['1']); $newsContent = ""; foreach ($newsData as $value) { $newsContent .= $value; } echo "<tr><th align='left'>$newsTitle</th><th align='right'>$submitDate</th></tr>"; echo "<tr><td colspan='2'>".$newsContent."<br/><br><hr size='1'/><br></td></tr>"; } ?> </table> </body> </div> </div> </td> </tr> </table> </td> </tr> </table> </div> </td> </tr> </table> </td> </tr> <tr height="61"> <td width="757" height="61" ALT="" valign="top" background="../bilder/hoved_design/bottom.jpg"> <table width="757" height="47" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="copy" width="360" valign="top"> <div style="margin-top:4px; margin-right:90px " align="center"> <div class="copy"> <font color="white">Copyright 2005-2007 © Noram Produkter A/S<br /> Design og utvikling av nettside - <a href="http://www.cloevvold-photo.com/" target="_blank">Cecilie Løvvold</a></font></div> </div> </td> <td align="center" width="397"> <div align="center" style="margin-top:26px " class="bot_men"> <div class="bottom_links"> <div class="bot_men"> </div> </div> </div> </td> </tr> </table> </td> </tr> </table> <!-- End ImageReady Slices --><br /> <br /> </body> </html> And this is the admin page: <? include "access.php"; ?> <?php if (!isset($_POST['submit'])) { ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html> <title>Noram Produkter AS</title> <head> <link href="style/style.css" rel="stylesheet" type="text/css" /> <script language="javascript" type="text/javascript" src="js/tiny_mce.js"></script> <script language="javascript" type="text/javascript"> tinyMCE.init({ mode : "textareas", theme : "advanced", theme_advanced_buttons3 : "", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", }); </script> </head> <body> <div id="main"> <div id="caption"><br /> Legg til Nyhet</div> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <br /> Tittel:<br/> <input type="text" name="title" size="40"/><br/><br/> Innhold:<br/> <textarea name="newstext" rows="15" cols="67"></textarea><br/> <right><input type="submit" name="submit" value="Legg Inn" /></right> </form> <div id="source"></div> </div> </body> <?php } else { $newsTitel = isset($_POST['title']) ? $_POST['title'] : 'Untitled'; $submitDate = date('d.m.Y'); $newsContent = isset($_POST['newstext']) ? $_POST['newstext'] : 'No content'; $filename = date('YmdHis'); $f = fopen('news/'.$filename.".txt","w+"); fwrite($f,$newsTitel."\n"); fwrite($f,$submitDate."\n"); fwrite($f,$newsContent."\n"); fclose($f); header('Location:index.php'); } ?> I altso use this script to login to admin.php: <? session_start(); $ADMIN_USER = "secret"; $ADMIN_PASSWORD = "secret"; if(!$_SESSION['authenticated']) if($_POST['loginbutton']) { $inputuser = $_POST['input_user']; $inputpassword = $_POST['input_password']; if(!strcmp($inputuser ,$ADMIN_USER) && !strcmp($inputpassword,$ADMIN_PASSWORD)) { $_SESSION['authenticated'] = 1; header("Location:".$_SERVER[php_SELF]); } else displayform(1); } else displayform(0); function displayform($error) { echo "<html><head><title>Please login</title></head><body><style>body,td,input { font-family: verdana; font-size: 8pt; }</style>"; if($error) echo "<p><b>Wrong credentials.</b></p>"; echo "<form action=\"\" method=\"post\"><table width='400' border=0><tr><td width='100'>username:</td>"; echo "<td><input type='text' name='input_user'></td></tr><tr><td>password:</td><td><input type='password' name='input_password'></td></tr>"; echo "<tr><td colspan='2'><input type='Submit' value='Login»' name='loginbutton'></td></tr></table></form></body></html>"; exit; } ?> Link to comment https://forums.phpfreaks.com/topic/75383-solved-i-have-a-problem-with-special-characters-%C3%A6%C3%B8%C3%A5-in-a-script/ Share on other sites More sharing options...
toplay Posted October 30, 2007 Share Posted October 30, 2007 The index page has the utf-8 setting correctly. Make sure the others do as well: <meta http-equiv="content-type" content="text/html; charset=utf-8" /> Link to comment https://forums.phpfreaks.com/topic/75383-solved-i-have-a-problem-with-special-characters-%C3%A6%C3%B8%C3%A5-in-a-script/#findComment-381302 Share on other sites More sharing options...
cloevvold Posted October 30, 2007 Author Share Posted October 30, 2007 Sorry... My bad :-\ I see what I have missed now.. Thanks for your answer Link to comment https://forums.phpfreaks.com/topic/75383-solved-i-have-a-problem-with-special-characters-%C3%A6%C3%B8%C3%A5-in-a-script/#findComment-381307 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.