i don't have any functions, heres the complete code so far
<?php
require_once('../Connections/noticias.php');
mysql_select_db($database_noticias, $noticias);
if (isset($HTTP_GET_VARS['cor'])) {
$data = $HTTP_POST_VARS['data'];
$titulo = $HTTP_POST_VARS['titulo'];
$resumo = $HTTP_POST_VARS['resumo'];
$noticia = $HTTP_POST_VARS['noticia'];
$idn = $HTTP_GET_VARS['idn'];
$query_alterarnoticia = "UPDATE noticias SET data='$data', titulo='$titulo', resumo='$resumo', noticia='$noticia' WHERE id = '$idn'";
$alterarnoticia = mysql_query($query_alterarnoticia, $noticias) or die(mysql_error());
if (!$alterarnoticia){
$resultado = "Noticia nao alterada";
} else {
$resultado = "Noticia alterada <br> <strong>" . $resultado . "</strong>" . ":<br><b>data: </b>" . $data . "<br><b>titulo: </b>" . $titulo . "<br><b>Resumo: </b><br>" . $resumo . "<p><b>Noticia: </b><br>" . $noticia;
}
}
if (isset ($HTTP_GET_VARS['el'])) {
$idn = $HTTP_GET_VARS['idn'];
echo $idn . "!!!!!!!";
$query_apagarnoticia = "DELETE FROM noticias WHERE id = '$idn'";
$apagarnoticia = mysql_query($query_apagarnoticia, $noticias) or die(mysql_error());
if (!$apagarnoticia){
$resultado = "Noticia nao eliminada";
} else {
$resultado = "Noticia eliminada"; }
}
if (!isset($HTTP_GET_VARS['el']) && !isset($HTTP_GET_VARS['cor']) && isset($HTTP_GET_VARS['idn'])) {
$idn = $HTTP_GET_VARS['idn'];
$query_detalhenoticia = "SELECT * FROM noticias WHERE id = '$idn'";
$detalhenoticia = mysql_query($query_detalhenoticia, $noticias) or die(mysql_error());
$row_detalhenoticia = mysql_fetch_assoc($detalhenoticia);
$totalRows_detalhenoticia = mysql_num_rows($detalhenoticia);
$data = $row_detalhenoticia['data'];
$resumo = $row_detalhenoticia['resumo'];
$titulo = $row_detalhenoticia['titulo'];
$noticia = $row_detalhenoticia['noticia'];
}
$query_titulos = "SELECT noticias.titulo, noticias.id FROM noticias";
$titulos = mysql_query($query_titulos, $noticias) or die(mysql_error());
$row_titulos = mysql_fetch_assoc($titulos);
$totalRows_titulos = mysql_num_rows($titulos);
?>
<html><head><title>NOTICIAS</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body>
<table width="780" border="0"><tr><td width="159">
<?php
do {
$link = "idn=".$row_titulos['id']."&action=".$HTTP_GET_VARS['action'];
echo "<a href=?".$link.">".$row_titulos['titulo']."</a><br>";
} while
($row_titulos = mysql_fetch_assoc($titulos));
?>
<div align="center"></div></td><td width="611">
<?php
if (!isset($HTTP_GET_VARS['cor']) && !isset($HTTP_GET_VARS['el']) && isset($HTTP_GET_VARS['idn'])) {?>
<form name="form1" method="post" action="index.php?idn=<?php echo $HTTP_GET_VARS['idn'];?>&action=noticias&cor=true">
<p align="center"> </p><p align="center">
data: <input name="data" type="text" id="data" value="<?php echo $data; ?>">
titulo: <input name="titulo" type="text" id="titulo" value="<?php echo $titulo;?>"></p><p align="center">
Resumo:<br><textarea name="resumo" cols="50" rows="2" id="resumo" ><?php echo $resumo; ?></textarea></p><p align="center">
Noticia:<br><textarea name="noticia" cols="70" rows="6" id="noticia"><?php echo $noticia; ?></textarea><br>
<input type="submit" name="Submit" value="Gravar"><input type="reset" name="Submit2" value="Repor"></form><br>
<a href="?el=true&idn=<?php echo $HTTP_GET_VARS['idn'];?>&action=noticias">apagar</a></p>
<?php
}
if (isset($HTTP_GET_VARS['cor'])) {
echo $resultado;
}
if (isset($HTTP_GET_VARS['el'])) {
echo $resultado;
}
?>
</td></tr></table></body></html>
<?php
mysql_free_result($titulos);
if(isset($HTTP_GET_VARS['cor'])) {
mysql_free_result($alterarnoticia);
}
if(isset($HTTP_GET_VARS['el'])) {
mysql_free_result($apagarnoticia);
}
if(isset($HTTP_GET_VARS['idn']) && !isset($HTTP_GET_VARS['cor']) && !isset($HTTP_GET_VARS['el'])) {
mysql_free_result($detalhenoticia);
}
?>
if i trie to free some result of any query the browser returns this:
Supplied argument is not a valid MySQL result resource
in the lines i have the mysql_free_result() corresponding to the query that has been done.