Foros del Web » Programando para Internet » PHP »

Mensaje de error

Estas en el tema de Mensaje de error en el foro de PHP en Foros del Web. Hola a todos, agradecería mucho vuestra ayuda y disculpar mi casi nulo conocimiento sobre PHP. Me sale el siguiente mensaje de error. A qué se ...
  #1 (permalink)  
Antiguo 28/05/2014, 09:44
 
Fecha de Ingreso: mayo-2014
Mensajes: 18
Antigüedad: 9 años, 10 meses
Puntos: 0
Exclamación Mensaje de error

Hola a todos, agradecería mucho vuestra ayuda y disculpar mi casi nulo conocimiento sobre PHP.

Me sale el siguiente mensaje de error. A qué se debe?

Parse error: syntax error, unexpected 'if' (T_IF) in /opt/lampp/htdocs/xxxxxxxxxx/validar.php on line 99

Código PHP:
                ".if(($registro['validar'])==0){echo"
                
<tr
                    <
td width='50%'><p align='right'><b>Validar:</b></td>
                    <
td width='50%'><p align='left'><input type='checkbox' name='validar' value='1'></td
                </
tr>

                <
tr
                    <
td width='50%'>&nbsp;</td
                    <
td width='50%'>&nbsp;</td
                </
tr>                
                <
input type='hidden' name='dni' value='$dni'
                <
tr
                    <
td width='100%' colspan='2'
                    <
p align='center'
                    <
input id='button' class='submit highRoundedCorners orangeBg whiteColor' type='submit' value='Registrar' name='B1' />
                    </
p></td>
                </
tr>
                
";}." 
Cuando realiza la consulta, el valor del campo de validar es igual a 0 (el usuario no está registrado) me salga la opción de activar registro.

Gracias de antemano!
  #2 (permalink)  
Antiguo 28/05/2014, 09:59
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: Mensaje de error

Por favor muestra el código completo, a simple vista parece que intentas concatenar una estructura lógica con una cadena y eso definitivamente está mal.

Los errores de sintaxis son importantes, ellos te indican que lo que haces no está permitido u omites algún carácter requerido.

Código PHP:
Ver original
  1. // MAL
  2. echo "algo de texto".if(condiction) {
  3.   // código...
  4. }."más texto";
  5.  
  6. // BIEN
  7. echo "algo de texto";
  8.  
  9. if (condicion) {
  10.   // código
  11. }
  12.  
  13. echo "más texto";

¿Se entiende el problema?
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #3 (permalink)  
Antiguo 28/05/2014, 10:12
 
Fecha de Ingreso: mayo-2014
Mensajes: 18
Antigüedad: 9 años, 10 meses
Puntos: 0
Exclamación Respuesta: Mensaje de error

Código PHP:

<?php  
$dni 
$_POST['dni'];

include(
'abre_conexion.php');   
    
    
$query "select * from $tabla_db1 where dni = '$dni'";
    
$result mysql_query($query);
    
$dni=$_REQUEST['dni'];  
$sql="SELECT dni FROM promocionmayo WHERE dni='$dni'";  
$res=mysql_query($sql);  
$total=mysql_num_rows($res);

if(
$total>0)  
{   

while (
$registro mysql_fetch_array($result)){ 

echo 

<body> 

<section>
<p class='logo-promo'><img src='http://192.168.1.100/promomayo/logo-40-anios.jpg'></p>
<h1 class='titulo-promo'>7 DIAS DE COLOR Y VOLUMEN EN LUIS&TACHI CON L’ORÉAL PROFESSIONNEL</h1>
</section>
  
  <section id='main'>
      <article class='container roundedCorners highBottomShadowed'>
      
          <article class='header whiteBg'>
              <h3 class='title blackColor'>Introduce el DNI del usuario</h3>
              <form action='validar.php' method='POST'>
                  <input id='input' class='input' autocomplete='off' type='text' name='dni'><br/>
                  <input id='button' class='submit highRoundedCorners orangeBg whiteColor' type='submit' value='Comprobar' name='B1' />
              </form>
          </article>

        <article class='header whiteBgDark'> 
            <table border='0' id='table1'> 
                <tr> 
                    <td colspan='2'><h3 align='center'>Revise y actualice los datos si es preciso</h3></td> 
                </tr> 
                <tr> 
                    <td class='min-text' colspan='2'>Compruebe si el usuario ha usado la promoción. En caso negativo, proceda a registrarlo mediante la casilla de validación</td> 
                </tr> 
                <form method='POST' action='actualiza.php'> 
                <tr> 
                    <td width='50%'>&nbsp;</td> 
                    <td width='50%'>&nbsp;</td> 
                </tr> 
                <tr> 
                    <td width='50%'><p align='right'><b>Nombre: </b></td> 
                    <td width='50%'><p align='center'><input type='text' name='nombre' size='20' value='"
.$registro['nombre']."'></td> 
                </tr> 
                <tr> 
                    <td width='50%'><p align='right'><b>Apellido:</b></td> 
                    <td width='50%'><p align='center'><input type='text' name='apellido' size='20' value='"
.$registro['apellido']."'></td> 
                </tr> 
                <tr> 
                    <td width='50%'><p align='right'><b>DNI:</b></td> 
                    <td width='50%'><p align='center'><input type='text' name='dni' size='20' value='"
.$registro['dni']."'></td> 
                </tr>
                <tr> 
                    <td width='50%'><p align='right'><b>PREMIO:</b></td> 
                    <td width='50%'><p align='center'><input type='text' name='dni' size='20' value='"
.$registro['premio']."'></td> 
                </tr>
                <tr> 
                    <td width='50%'><p align='right'><b>SALÓN:</b></td> 
                    <td width='50%'><p align='center'><input type='text' name='dni' size='20' value='"
.$registro['salon']."'></td> 
                </tr>
                <tr> 
                    <td width='50%'><p align='right'><b>FECHA REDENCIÓN:</b></td> 
                    <td width='50%'><p align='center'><input type='text' name='dni' size='20' value='"
.$registro['fecha_redencion']."'></td> 
                </tr>
                <tr> 
                    <td width='50%'>&nbsp;</td> 
                    <td width='50%'>&nbsp;</td> 
                </tr> 
                <tr> 
                    <td width='100%' colspan='2'>
                        <p align='center'>
                            Este usuario <b>"
. ($registro['validar'] ? 'SI' 'NO') ."</b> está registrado
                        </p>
                    </td> 
                </tr> 
                <tr> 
                    <td width='50%'>&nbsp;</td> 
                    <td width='50%'>&nbsp;</td> 
                </tr>
                
                "
.if(($registro['validar'])==0){echo"
                <tr> 
                    <td width='50%'><p align='right'><b>Validar:</b></td>
                    <td width='50%'><p align='left'><input type='checkbox' name='validar' value='1'></td> 
                </tr>

                <tr> 
                    <td width='50%'>&nbsp;</td> 
                    <td width='50%'>&nbsp;</td> 
                </tr>                
                <input type='hidden' name='dni' value='$dni'> 
                <tr> 
                    <td width='100%' colspan='2'> 
                    <p align='center'> 
                    <input id='button' class='submit highRoundedCorners orangeBg whiteColor' type='submit' value='Registrar promoción' name='B1' />
                    </p></td>
                </tr>
                "
;}."
                
                <tr> 
                    <td width='50%'>&nbsp;</td> 
                    <td width='50%'>&nbsp;</td> 
                </tr> 
                </form> 
            </table> 
        </article>

      </article>
  </section>

"

}
}  
else  
{  
  echo 
"
<body> 

<section>
<p class='logo-promo'><img src='http://192.168.1.100/promomayo/logo-40-anios.jpg'></p>
<h1 class='titulo-promo'>7 DIAS DE COLOR Y VOLUMEN EN LUIS&TACHI CON L’ORÉAL PROFESSIONNEL</h1>
</section>
  
  <section id='main'>
      <article class='container roundedCorners highBottomShadowed'>
      
          <article class='header whiteBg'>
              <h3 class='title blackColor'>Introduce el DNI del usuario</h3>
              <form action='validar.php' method='POST'>
                  <input id='input' class='input' autocomplete='off' type='text' name='dni'><br/>
                  <input id='button' class='submit highRoundedCorners orangeBg whiteColor' type='submit' value='Comprobar' name='B1' />
              </form>
          </article>

        <article class='header whiteBgDark'>
        <p class='max-text'>Este usuario NO está premiado</p>
        </article>

      </article>
  </section>
  
  "
;  
}

include(
'cierra_conexion.php');   
?>
  #4 (permalink)  
Antiguo 28/05/2014, 10:22
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: Mensaje de error

Dicho y hecho, lee mi mensaje anterior y reflexiona mi respuesta, estás combinando sintaxis de manera indebida.
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #5 (permalink)  
Antiguo 28/05/2014, 10:29
 
Fecha de Ingreso: mayo-2014
Mensajes: 18
Antigüedad: 9 años, 10 meses
Puntos: 0
Respuesta: Mensaje de error

Muchas gracias por echarme una mano. Voy a reflexionar a ver si soy capaz de entenderlo

Etiquetas: unexpected
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 07:22.