Ver Mensaje Individual
  #9 (permalink)  
Antiguo 26/12/2006, 22:52
albertt_t
 
Fecha de Ingreso: noviembre-2004
Mensajes: 159
Antigüedad: 21 años, 11 meses
Puntos: 0
De acuerdo Re: actualizar registros. Que me anda mal!!!!

Cita:
Iniciado por bellacord Ver Mensaje
Código PHP:
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset(
$_SERVER['QUERY_STRING'])) {
  
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset(
$_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  
$updateSQL = sprintf("UPDATE noticias SET created=%s, noticia_titulo=%s, texto=%s WHERE id_noticias=%s",
                       
GetSQLValueString($_POST['created'], "date"),
                       
GetSQLValueString($_POST['noticia_titulo'], "text"),
                       
GetSQLValueString($_POST['texto'], "text"),
                       
GetSQLValueString($_POST['id_noticias'], "int"));

  
mysql_select_db($database_promautos, $promautos);
  
$Result1 = mysql_query($updateSQL, $promautos) or die(mysql_error());

  
$updateGoTo = "actualizado.php";
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    
$updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  
header(sprintf("Location: %s", $updateGoTo));
}

$colname_noticias = "-1";
if (isset(
$_GET['id_noticias'])) {
  
$colname_noticias = (get_magic_quotes_gpc()) ? $_GET['id_noticias'] : addslashes($_GET['id_noticias']);
}
mysql_select_db($database_promautos, $promautos);
$query_noticias = sprintf("SELECT * FROM noticias WHERE id_noticias = %s", $colname_noticias);
$noticias = mysql_query($query_noticias, $promautos) or die(mysql_error());
$row_noticias = mysql_fetch_assoc($noticias);
$totalRows_noticias = mysql_num_rows($noticias);

?>


Ese es el codigo completo, sin los html
ok Bellacord, si revisamos el id que pasas por get


Código PHP:
noticiasdetalles.php?id_noticia=<?php echo $row_noticias['id_noticias']; ?>
Código:
id_noticia
y si revisamos lo que tu codigo recibe

Código PHP:
'id_noticias' 
Agregale la 's' al id_noticia

Saludos

A. Acosta

P.D. Particularmente pienso que las extensiones de dreamweaver generan mucho codigo. Hay muchos ejemplos en el foro (como para obviar tanto codigo que genera el dream). Te recomiendo les des una revisada