Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/06/2004, 07:28
Avatar de oskitar
oskitar
 
Fecha de Ingreso: junio-2002
Mensajes: 245
Antigüedad: 21 años, 10 meses
Puntos: 1
¿Error en el código? A ver si me podeis ayudar

Muy buenas, tengo el siguiente código y no se k le pasa, pero no me va....

No se k es lo mal, es la primera vez k intento un update y no me sale.

tengo dos archivos. El primero:

Código PHP:
<?
$link 
mysql_connect("localhost","empresaria","plazaadra2003");
mysql_select_db("almeriaempresaria_com"$link);
if(!
mysql_select_db) {echo "No se ha podido conectar a la bd";}
$sql"SELECT * FROM CLIENTE WHERE idcliente='".$_GET['idcliente']."'";
$resultmysql_query($sql$link);
if(
$row=mysql_fetch_array($result)){
echo 
"<form action='guardar.php' method='post'>\n";
echo 
"<table width=100% border=0><tr><td width=30% style='font-family:Verdana; font-size:10px'>Idcliente</td><td width=70%><input size=30 style='font-family:Verdana; font-size:10px' type=\"text\" name=\"idcliente\" value=\"".$row["idcliente"]."\"></td></tr>\n";
echo 
"<table width=100% border=0><tr><td width=30% style='font-family:Verdana; font-size:10px'>Nombre</td><td width=70%><input size=30 style='font-family:Verdana; font-size:10px' type=\"text\" name=\"nombre\" value=\"".$row["nombre"]."\"></td></tr>\n";
echo 
"<table width=100% border=0><tr><td width=30% style='font-family:Verdana; font-size:10px'>Dirección</td><td width=70%><input size=30 style='font-family:Verdana; font-size:10px' type=\"text\" name=\"direcc\" value=\"".$row["direccion"]."\"></td></tr>\n";
echo 
"<table width=100% border=0><tr><td width=30% style='font-family:Verdana; font-size:10px'>Ciudad</td><td width=70%><input size=30 style='font-family:Verdana; font-size:10px' type=\"text\" name=\"city\" value=\"".$row["ciudad"]."\"></td></tr>\n";
echo 
"<table width=100% border=0><tr><td width=30% style='font-family:Verdana; font-size:10px'>Código Postal</td><td width=70%><input size=30 style='font-family:Verdana; font-size:10px' type=\"text\" name=\"cp\" value=\"".$row["cp"]."\"></td></tr>\n";
echo 
"<table width=100% border=0><tr><td width=30% style='font-family:Verdana; font-size:10px'>Teléfono</td><td width=70%><input size=30 style='font-family:Verdana; font-size:10px' type=\"text\" name=\"telef\" value=\"".$row["telef"]."\"></td></tr>\n";
echo 
" <table width=100% border=0><tr><td width=100% style='font-family:Verdana; font-size:10px'><input type=\"submit\" value=\"Guardar\"></td></tr>\n";
echo 
"</table></form>";}
?>
Este archivo viene de otro del k sako el idcliente.

y ejecuta este:

Código PHP:
<?
$DOCUMENT_ROOT 
$HTTP_SERVER_VARS['DOCUMENT_ROOT'];
$idcliente $HTTP_POST_VARS['idcliente'];
$nombre $HTTP_POST_VARS['nombre'];
$direcc $HTTP_POST_VARS['direcc'];
$city $HTTP_POST_VARS['city'];
$cp $HTTP_POST_VARS['cp'];
$telef $HTTP_POST_VARS['telef'];
?>
<html>
<head>
<title>Resultado de la operaci&oacute;n</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<?
$link
=mysql_connect("localhost","empresaria","plazaadra2003");
mysql_select_db("almeriaempresaria_com",$link);
if(!
mysql_select_db){
echo 
"No se ha podido conectar a la bd";}
else{
$sql="UPDATE CLIENTE SET  nombre=$nombre, direccion=$direcc, ciudad=$city, cp=$cp, telef=$telef WHERE idcliente=$idcliente";
$result=mysql_db_query($sql,$link);
if(!
$result){
echo 
"<table><tr><td style='font-family:Verdana; font-size:10px'>No se ha podido realizar la operación.</td></tr></table>\n";
echo 
"<table><tr><td style='font-family:Verdana; font-size:10px'><a href=\"javascript:history.back()\"><img src=\"atras.gif\" border=\"0\"></a></td></tr>\n";
echo 
"</table>";}
else{
echo 
"<head><META http-equiv=\"refresh\" content =\"5; URL=clientes.php\"></head>\n";
echo 
"<table><tr><td style='font-family:Verdana; font-size:10px'>Operación realizada.</td></tr>\n";
echo 
"</table>";}}
?>
<body>
</body>
</html>
No se k pasa k siempre me devuelte el texto k le puse a !$result...

a ver si podeis ayudarme

saludos