Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Estou com os códigos abaixo para comentar nas noticias que são atualizadas diariamente em diferentes categorias, porém os comentários não vão nem para o banco de dados. O que está acontecendo?
Obrigada.
Código php para puxar o comentário para a página:
<?php include('coment.php'); ?>
Código para comentar
<?php
$colname_coment = "-1";
if (isset($_GET['noticia'])) {
$colname_coment = (get_magic_quotes_gpc()) ? $_GET['noticia'] : addslashes($_GET['noticia']);
}
mysql_select_db(xxx);
$query_coment = sprintf("SELECT * FROM coment WHERE com_not = %s ORDER BY com_id DESC", $colname_coment);
$coment = mysql_query(xxx) or die(mysql_error());
$row_coment = mysql_fetch_assoc($coment);
$totalRows_coment = mysql_num_rows($coment);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="[http://www.w3.org/1999/xhtml"](http://www.w3.org/1999/xhtml) xml:lang="pt-br" lang="pt-br">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
<!--
body,td,th {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
}
.style1 {
color: #1C4E92;
font-weight: bold;
}
.style2 {color: #1C4E92}
.style3 {font-family: Verdana}
-->
</style>
<table width="447" height="434" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td width="445" align="left"><p class="style1 style3">Comente: </p> </td>
</tr>
<tr>
<td><form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<table width="410" align="center" bgcolor="#FFFFFF">
<tr>
<td width="43" align="left"><span class="style2">Nome:</span> </td>
<td width="355" align="left"><input name="nome" type="text" id="nome" size="42" /></td>
</tr>
<tr>
<td height="32" align="left"><span class="style2">E-mail</span>: </td>
<td align="left"><input name="email" type="text" id="email" size="42" /></td>
</tr>
<tr>
<td colspan="2" align="left"><p class="style1"> </p>
<p class="style2">Comente:</p></td>
</tr>
<tr>
<td colspan="2" align="right"><div align="left">
<textarea name="comentario" cols="65" rows="7" id="comentario"></textarea>
</div></td>
</tr>
<tr>
<td height="35" colspan="2" align="left"><input type="image" src="img/coment.jpg" name="Submit" value="Comentar" /></td>
</tr>
</table>
<input name="ip" type="hidden" id="ip" value="<? echo $_SERVER['REMOTE_ADDR']; ?>" />
<input type="hidden" name="MM_insert" value="form1" />
</form></td>
</tr>
<tr>
<td align="left"><span class="style2"><strong>Comentários:</strong></span></td>
</tr>
<tr>
<td height="111"><?php do { ?>
<table width="400" cellpadding="0" cellspacing="5" bgcolor="#FFFFFF">
<tr>
<td colspan="2" align="left" valign="top"><span class="style2"><?php echo nl2br($row_coment['com_com']); ?></span></td>
</tr>
<tr>
<td align="left" valign="bottom"><br />
<span class="style2"><?php echo $row_coment['com_nom']; ?></span></td>
<td align="right" valign="bottom"><span class="style2"><?php echo $row_coment['com_date']; ?></span></td>
</tr>
<tr>
<td height="1" colspan="2" bgcolor="#FF0000"></td>
</tr>
</table>
<?php } while ($row_coment = mysql_fetch_assoc($coment)); ?></td>
</tr>
</table>
<?php
mysql_free_result($coment);
?>
Para listar os comentarios:
<?php require_once('xxx'); ?>
<?php require_once('xxx'); ?>
<?php
$colname_coment = "-1";
if (isset($_GET['noticia'])) {
$colname_coment = (get_magic_quotes_gpc()) ? $_GET['noticia'] : addslashes($_GET['noticia']);
}
mysql_select_db(xxx);
$query_coment = sprintf("SELECT * FROM coment WHERE com_not = %s", $colname_coment);
$coment = mysql_query(xxx) or die(mysql_error());
$row_coment = mysql_fetch_assoc($coment);
$totalRows_coment = mysql_num_rows($coment);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">](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>Area Administrativa</title>
<style type="text/css">
<!--
body,td,th {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
}
-->
</style></head>
<body>
<?php do { ?>
<table width="450" cellpadding="3" cellspacing="0">
<tr>
<td colspan="4"><?php echo $row_coment['com_com']; ?></td>
</tr>
<tr>
<td width="174"><?php echo $row_coment['com_nom']; ?></td>
<td width="132"> <?php echo $row_coment['com_email']; ?></td>
<td colspan="2"> </td>
</tr>
<tr>
<td><?php echo $row_coment['com_date']; ?></td>
<td colspan="2"><?php echo $row_coment['com_ip']; ?></td>
<td width="48"><a href="del_com.php?comentario=<?php echo $row_coment['com_id']; ?>">Excluir</a></td>
</tr>
<tr>
<td height="1" colspan="4" bgcolor="#000000"></td>
</tr>
</table>
<?php } while ($row_coment = mysql_fetch_assoc($coment)); ?>
<a href="listar_noticia.php"><br />
Voltar</a>
</body>
</html>
<?php
mysql_free_result($coment);
?>Carregando comentários...