Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Olá galera estou terminando de fazer um site mas só falta resolver um problema, fiz o seguinte sistema de notícias, simples...
e quando coloco o include para puxar o arquivo noticias.php para a pagina index.php os caracteres com acentos ficam assim: � (um ponto de interrogação) mas o mais estranho é que quando acesso a pagina noticias.php em link direto os caracteres aparecem normalmente!
no banco de dados os caracteres são "utf8_unicode_ci" e na pagina index.php está "<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />"
Enviar.php (responsavel por inserir a notícia no DB)
<?
include 'config_not.php';
$titulo = $_POST['titulo'];
$noticia = $_POST['mensagem'];
$gm = $_POST['gm'];
$data = $_POST['data'];
if($noticia == null){
echo '<h1>Preencha o campo mensagem!!</h1>';
exit();
}
if($gm == null){
echo '<h1>Preencha o campo GM!!</h1>';
exit();
}
if($data == null){
echo '<h1>Preencha o campo data!!</h1>';
exit();
}
$inserir = mysql_query("insert into noticias (titulo, noticia, por, data) values ('$titulo', '$noticia', '$gm', '$data')");
if($inserir > 0){
echo 'mensagem enviada com sucesso!!!<br/>';
echo '<a href="index.php">Voltar para o site</a>';echo 'mensagem não enviada com sucesso!!!<br/>';
echo '<a href="index.php">Voltar para o site</a>';
}
?>
Inserir.php (formulario para criar notícia)
<? include 'config_not.php'; ?>
<!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">](http://www.w3.org/1999/xhtml)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>inserir</title>
<style type="text/css">.style1 {
font-family: "Courier New", Courier, monospace;
color: #666666;
}
.style3 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #FF0000;
}
.style4 {
font-family: Georgia, "Times New Roman", Times, serif;
font-size: 18px;
color: #333333;
}
.style5 {
font-family: Arial, Helvetica, sans-serif;
font-size: 9px;
color: #999999;
}</style>
</head>
<body>
<form name="form" method="post" action="enviar.php">
<p class="style4">Sistema de notícias RagnaPremium</p>
<table width="768" height="156" border="0">
<tr>
<td><span class="style1">Título:</span></td>
<td><input type="text" name="titulo" />
<span class="style1">( 10.10.10 - Nova notícia)</span></td>
<td class="style3">Colocar o título</td>
</tr>
<tr>
<td width="127"><span class="style1">Notícia:</span> </td>
<td width="500"><textarea name="mensagem" cols="60" rows="10"></textarea></td>
<td width="127" class="style3">Colocar o título seguido da notícia.</td>
</tr>
<tr>
<td class="style1">Escrito por: </td>
<td><input type="text" name="gm" />
<span class="style1">( ADM Teste)</span></td>
<td><span class="style3">Seu cargo (GM, ADM...) e seu nick.</span></td>
</tr>
<tr>
<td class="style1">Data:</td>
<td><input type="text" name="data" />
<span class="style1">( 10.10.10 )</span> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="Enviar Notícia" /></td>
<td> </td>
</tr>
</table></form>
<p> </p>
</body>
</html>
Noticias.php (exibe a notícia no site)
<? include 'config_not.php' ?>
<?
$sql = 'select * from noticias order by id desc limit 5';
$executar = mysql_query($sql);
while ($exibir = mysql_fetch_array($executar)){
echo '<table width="500" border="0">
<tr>
<td width="417" class="titulonoti">'.$exibir['titulo'].'</td>
<td width="73"><div align="center" class="vermais">VER +</div></td>
</tr>
</table>Obrigado.
Carregando comentários...