Foros del Web » Programando para Internet » PHP »

actualizar registros. Que me anda mal!!!!

Estas en el tema de actualizar registros. Que me anda mal!!!! en el foro de PHP en Foros del Web. Código PHP: noticiasdetalles.php?id_noticia= <?php  echo  $row_noticias [ 'id_noticias' ];  ?> este es el enlace q tengo a la pagina de editar las noticias,. como podran ...
  #1 (permalink)  
Antiguo 22/12/2006, 14:12
 
Fecha de Ingreso: junio-2003
Ubicación: Frente al monitor
Mensajes: 508
Antigüedad: 20 años, 10 meses
Puntos: 0
actualizar registros. Que me anda mal!!!!

Código PHP:
noticiasdetalles.php?id_noticia=<?php echo $row_noticias['id_noticias']; ?>
este es el enlace q tengo a la pagina de editar las noticias,. como podran ver tengo el $row_noticias q supuestament es query, los id estan tambien, esto aparece en la parte de admin de noticias...


en la pagina noticiasdetalles.php tengo un juego de registro para actualizar q se llama noticias cuando le doy click al enlace noticiasdetalles.php?id_.... me manda a la pagina de noticiasdetalles.php pero no me muestra los cnontenidos, el url q me da es este por ejemplo para el id 1 noticiasdetalles.php?id_noticia=1, esta algo mal puesto en los parametros y valores? o es en la parte de noticiasdetalles
__________________
Tengo una duda...
  #2 (permalink)  
Antiguo 22/12/2006, 16:54
 
Fecha de Ingreso: noviembre-2004
Mensajes: 159
Antigüedad: 19 años, 5 meses
Puntos: 0
Re: actualizar registros. Que me anda mal!!!!

Saludos,

Podrias poner el codigo de noticiasdetalles.php

Gracias ;)

A. Acosta
  #3 (permalink)  
Antiguo 22/12/2006, 18:33
 
Fecha de Ingreso: junio-2003
Ubicación: Frente al monitor
Mensajes: 508
Antigüedad: 20 años, 10 meses
Puntos: 0
Re: actualizar registros. Que me anda mal!!!!

q parte del codigo quiereS¿ los querys¿


ahi solo hay un formulario con los campos a actualizar
__________________
Tengo una duda...
  #4 (permalink)  
Antiguo 22/12/2006, 18:47
Avatar de .php  
Fecha de Ingreso: julio-2006
Mensajes: 481
Antigüedad: 17 años, 9 meses
Puntos: 5
Re: actualizar registros. Que me anda mal!!!!

mmm.
haz esta prueba en la cabezara de la pagina noticiasdetalles.php
escribe esto
Código PHP:
echo $_GET["id_noticia"]; 
si no te muestra nada es por que no tiene nada
oooo jajajja que brujo soy..
__________________
~~[FiDeLio]~~
  #5 (permalink)  
Antiguo 23/12/2006, 08:29
 
Fecha de Ingreso: octubre-2003
Ubicación: Montevideo-Uruguay
Mensajes: 49
Antigüedad: 20 años, 6 meses
Puntos: 0
Re: actualizar registros. Que me anda mal!!!!

Estimado bellacord;

Cuando a través del navegador intentas vel el código fuente que contiene la linea:

noticiasdetalles.php?id_noticia=<?php echo $row_noticias['id_noticias']; ?>

que es lo que ves? ves algo como:

noticiasdetalles.php?id_noticia=1

o el número que sea, porque quizás lo que este pasando es que id_noticia sea nulo, aunque por tu mensaje creo que lo estás haciendo bien.

Qué tiene adentro noticiasdetalles.php? Cómo lees el parámetro id_noticia dentro de noticiasdetalles.php?

Quizás ahi este el problema.

Última edición por jam1138; 27/12/2006 a las 00:04 Razón: Utilizar el espacio dedicado para las firmas
  #6 (permalink)  
Antiguo 23/12/2006, 21:51
 
Fecha de Ingreso: noviembre-2004
Mensajes: 159
Antigüedad: 19 años, 5 meses
Puntos: 0
De acuerdo Re: actualizar registros. Que me anda mal!!!!

Cita:
Iniciado por bellacord Ver Mensaje
q parte del codigo quiereS¿ los querys¿


ahi solo hay un formulario con los campos a actualizar
Correcto, me gustaria ver el codigo de ese archivo noticiasdetalles.php

Estoy seguro que rescatar la información de ese ID y luego imprimes el valor dentro de los text box. Me gustaria ayudarte pero sería ideal si posteas el codigo.

Saludos

A. Acosta
  #7 (permalink)  
Antiguo 25/12/2006, 02:45
Avatar de vevni  
Fecha de Ingreso: julio-2005
Ubicación: cancun mexico
Mensajes: 598
Antigüedad: 18 años, 9 meses
Puntos: 3
Re: actualizar registros. Que me anda mal!!!!

si postea el codigo para poder ver como recoges el id.
saluds!
__________________
Código PHP:
echo"hola mundo ver 1221332143.02";
echo
"cuantos usuarios habran impreso hola mundo en el mundo.!???"
  #8 (permalink)  
Antiguo 26/12/2006, 08:17
 
Fecha de Ingreso: junio-2003
Ubicación: Frente al monitor
Mensajes: 508
Antigüedad: 20 años, 10 meses
Puntos: 0
Re: actualizar registros. Que me anda mal!!!!

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
__________________
Tengo una duda...
  #9 (permalink)  
Antiguo 26/12/2006, 22:52
 
Fecha de Ingreso: noviembre-2004
Mensajes: 159
Antigüedad: 19 años, 5 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
  #10 (permalink)  
Antiguo 27/12/2006, 01:36
 
Fecha de Ingreso: septiembre-2006
Ubicación: Argentina
Mensajes: 190
Antigüedad: 17 años, 7 meses
Puntos: 1
Re: actualizar registros. Que me anda mal!!!!

Si el tip anterior no va (porque te equivocaste en tu primer post) probá esto:

Código PHP:
SELECT FROM noticias WHERE id_noticias = %
por esto:

Código PHP:
SELECT FROM noticias WHERE id_noticias '%s' 

Saludos.
  #11 (permalink)  
Antiguo 27/12/2006, 07:28
 
Fecha de Ingreso: junio-2003
Ubicación: Frente al monitor
Mensajes: 508
Antigüedad: 20 años, 10 meses
Puntos: 0
Re: actualizar registros. Que me anda mal!!!!

ya todo bien. gracias, lo k hice fue ponerle la s a id_noticias, como me ha dicho albertt_t
__________________
Tengo una duda...
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 09:56.