PDA

Ver la Versión Completa : Problemas De Sintaxis If..else


CARLOS E
06-06-2006, 05:51:29
HOLA..
TENGO UNA PAGINA DONDE CAPTURO CIERTOS DATOS Y OTRA DONDE SE MUESTRA CUALES FUERON LOS CAMPOS DONDE NO SE TECLEO INFORMACION(DEBIDO A QUE SERAN OBLIGATORIOS). EL PROBLEMA ES QUE TIEMPO ANTES FUNCIONABA Y HOY NO, NO RECUERDO HABER MODIFICADO EL SCRIPT PERO AUN SIENDO MUY SENCILLO NO HE ENCONTRADO EL ERROR Y ME DESPLIEGA EL TEXTO MOSTRADO ABAJO....
ADEMAS QUE DENTRO DE LAS MISMAS CIRCUNSTANCIAS EN OCASIONES MODIFICO UNA SENTENCIA "IF" Y AL REGRESARLA AL ESTADO ANTERIOR SE COMPORTA DIFERENTE (ME DESPLIEGA UN RESULTADO DISTINTO)..

OTRO PROBLEMA, QUE PASA CON LOS SALTOS DE LINEA? NO VEO QUE ME FUNCIONEN NI EN ESTE NI EN NINGUN SCRIPT :confused:

ESPERO HABER EXPRESADO BIEN MI PROBLEMA , GRACIAS!

USO PHP 4.4.2.2

CODIGO::

<?php
$err_an=0;
if($_post['titulo_an']=="")
{
echo "El campo de TITULO es obligatorio \n";
$err_an=1;
}
if($_post['descripcion_an']=="")
{
echo "El campo de DESCRIPCION es obligatorio \n";
$err_an=1;
}
if($_post['categoria_an']=="")
{
echo "Debe seleccionar la Categoria \n";
$err_an=1;
}
if($_post['subcategoria_an']=="")
{
echo "Debe seleccionar la Subcategoria \n";
$err_an=1;
}
$nombre_an= $_files['archivo_an']['name'];
$tipo_an= $_files['archivo_an']['type'];
$tamaño_an= $_files['archivo_an']['size'];
$ruta_an=$_files['tmp_name'];
$contenido_an=addslashes(file_get_contents($ruta_an));
if ( $contenido_an != false)
{
if ($tipo_an=="image/jpeg" || $tipo_an=="image/gif" || $tipo_an=="image_pjpeg" || $tipo_an=="image/bmp")
{
if ($tamaño_an > '102000')
{
echo " El tamaño de la imagen debe ser menor a 100 kb. \n";
$err_an=1;
}
}
else
{
echo "Solo se aceptan formatos de imagen BMP,JPG y GIF \n";
$err_an=1;
}
}



RESULTADO ::


Debe seleccionar la Subcategoria \n"; $err_an=1; } $nombre_an= $_files['archivo_an']['name']; $tipo_an= $_files['archivo_an']['type']; $tamaño_an= $_files['archivo_an']['size']; $ruta_an=$_files['tmp_name']; $contenido_an=addslashes(file_get_contents($ruta_an)); if ( $contenido_an != false) { if ($tipo_an=="image/jpeg" || $tipo_an=="image/gif" || $tipo_an=="image_pjpeg" || $tipo_an=="image/bmp") { if ($tamaño_an > '102000') { echo "
El tamaño de la imagen debe ser menor a 100 kb."; $err_an=1; } } else { echo "Solo se aceptan formatos de imagen BMP,JPG y GIF"; $err_an=1; } } function alta_anuncio (&$res_an, $contenido_an, $tipo_an) { $res_an=0; $conexion_an=mysql_connect("localhost","root",""); if (! $conexion_an) { return $res_an; exit; } else { $db_sel_an=mysqlselect_db("bdregistros", $conexion_an); $sqlx ="insert into anuncios (id_anuncio,id_cte,fecha,hora,titulo_an,descrip,cve_cat,cve_subcat,url,mail,precio,img1,tipo_img,cd, edo,cve_tipo,vigente) values ('0','0000',curdate(),curtime(),'".$_post["titulo_an"]."','".$_post["descripcion_an"]."','01','0100','".$_post["url_an"]."','".$post["correo_an"]."'.'".$_post["precio_an"]."','".$contenido_an."','".$_post["ciudad_an"]."','".post["estado_an"]."',ACCOO','1')"; $result_an=mysql_query($sqlx) or die(mysql_error()); if (! $result_an) { return $res_an; exit; } else { $res_an=1; mysql_close($conexion_an); if(file_exists($ruta_an)) unlink($ruta_an); } } return $res_an; } ?>

kayetano
06-06-2006, 08:51:56
Hola

Lo primero, NO GRITES, el escribir en mayusculas significa gritar, mucho mejor en minusculas.

El salto de linea en HTML es <br> el "\n" es para el codigo fuente.

Por lo demás no veo nada raro, solvo el uso de minúsculas en los nombres de arrays $_POST y $_FILES pero dudo que tenga algo que ver.

¿Es este todo el código del script? ¿podrías mostrar el código del formulario?

CARLOS E
07-06-2006, 05:53:19
Me He Dado Cuenta Con Otros Ejemplos Que Hice Que El Problema No Es La Sintaxis, Sino Que En Ocasiones Si Ejecuta El Codigo Php(aunque De Manera Erronea) Y En Otras No, Pero Aun Reinstalandolo Continuo Con El Problema. A Que Podra Deberse? Podria Tener Algo Que Ver El Servidor Apache Que Tengo Instalado?

Estoy Muy Confundido, Cualquier Opinion Sera Agradecida, Gracias!!