Foros del Web » Programando para Internet » PHP »

Parse error: syntax error, unexpected $end

Estas en el tema de Parse error: syntax error, unexpected $end en el foro de PHP en Foros del Web. Hola!! cómo están?? Tengo un problema.. tengo un script en php que me da este error: Parse error: syntax error, unexpected $end in /home/av000340/public_html/clientes/admin/usuario.php on ...
  #1 (permalink)  
Antiguo 27/08/2008, 16:22
Avatar de fakulicious  
Fecha de Ingreso: mayo-2008
Ubicación: Mendoza
Mensajes: 140
Antigüedad: 16 años
Puntos: 2
Exclamación Parse error: syntax error, unexpected $end

Hola!! cómo están??

Tengo un problema.. tengo un script en php que me da este error:

Parse error: syntax error, unexpected $end in /home/av000340/public_html/clientes/admin/usuario.php on line 144

ya revisé todas las aperturas de if, elseif, else, while, y funciones y todas están bien..

copio el código a ver si alguien encuentra el error..

Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Acciones de Usuario</title>
<link href="../estilos.css" rel="stylesheet" type="text/css" />
<script src="js.js"></script>
</head>
<body onUnload="opener.location.reload();">
<p>
  <?php
$mod 
$_GET['mod'];
$id_usr $_GET['id_usr'];
$accion $_GET['accion'];

include (
'config.php');

if (
$mod == 'eliminar'){
    
$res mysql_query("DELETE * FROM usuarios WHERE id_usr = $id_usr LIMIT 1;"$link);
    
    if (!
$res){
        echo 
'<p aling="center"><strong>No se ha podido eliminar el usuario.</strong></p>
                <p aling="center">&nbsp;</p>
                <p aling="center">Revise las configuraciones o contáctese con el administrador.</p>
                <p aling="center">&nbsp;</p>
                <p aling="center"><a href="javascript:window.close()">Cerrar</a></p>'
;
    } else {
        echo 
'<p aling="center"><strong>El usuario ha sido eliminado.</strong></p>
                <p aling="center">&nbsp;</p>
                <p aling="center"><a href="javascript:window.close()">Cerrar</a></p>'
;
    }
} else {
    
$res mysql_query("SELECT * FROM usuarios WHERE id_usr = $id_usr LIMIT 1;"$link);
    
    while (
$row myaql_fetch_row($res)){
        if (
$mod == 'editar' || $accion == 'guardar'){
            
$tipo_usr $_POST['tipo_usr'];
            
$nombre $_POST['nombre'];
            
$apellido $_POST['apellido'];
            
$email $_POST['email'];
                
            
$consulta mysql_query("UPDATE usuarios SET tipo_usr = '$tipo_usr', nombre = '$nombre', apellido = '$apellido', email = '$email' WHERE id_usr = $id_usr LIMIT 1;"$link);
            
            if (!
consulta){
                echo 
'<p aling="center"><strong>No se ha podido editar el usuario.</strong></p>
                <p aling="center">&nbsp;</p>
                <p aling="center">Revise las configuraciones o contáctese con el administrador.</p>
                <p aling="center">&nbsp;</p>
                <p aling="center"><a href="javascript:window.close()">Cerrar</a></p>'
;
            } else {
                echo 
'<p aling="center"><strong>El usuario ha sido editado.</strong></p>
                <p aling="center">&nbsp;</p>
                <p aling="center"><a href="javascript:window.close()">Cerrar</a></p>'
;
            }
        } elseif (
$mod == 'editar' || $accion != 'guardar'){ ?>
</p>
<form id="form1" name="form1" method="post" action="usuario.php?mod=editar&amp;accion=guardar">
  <table width="350" border="0" cellspacing="3" cellpadding="0">
    <tr>
      <td colspan="2" class="subtitulos_inicio">Editar Usuario </td>
    </tr>
    <tr>
      <td width="175" class="titulo_input">Tipo de Usuario </td>
      <td width="175" class="arriba"><select name="tipo_usr" id="tipo_usr">
        <option value="empleado" <?php if ($row[1] == 'empleado'){ echo 'selected="selected"'; }?>>Empleado</option>
        <option value="admin" <?php elseif ($row[1] == 'admin'){ echo 'selected="selected"'; }?>>Administrador</option>
        <option value="cliente" <?php elseif ($row[1] == 'cliente'){ echo 'selected="selected"'; }?>>Cliente</option>
      </select>      </td>
    </tr>
    <tr>
      <td width="175" class="titulo_input">Nombre</td>
      <td width="175" class="arriba"><input name="nombre" type="text" id="nombre" value="<?php echo $row[4]; ?>" /></td>
    </tr>
    <tr>
      <td width="175" class="titulo_input">Apellido</td>
      <td width="175" class="arriba"><input name="apellido" type="text" id="apellido" value="<?php echo $row[5]; ?>" /></td>
    </tr>
    <tr>
      <td class="titulo_input">E-Mail</td>
      <td class="arriba"><input name="email" type="text" id="email" value="<?php echo $row[6]; ?>" /></td>
    </tr>
    <tr>
      <td colspan="2" align="center"><input name="usuario" type="hidden" id="usuario" value="<?php echo $row[2]; ?>" />
        <input name="pass1" type="hidden" id="pass1" value="<?php echo $row[3]; ?>" />
          <input name="pass2" type="hidden" id="pass2" value="<?php echo $row[3]; ?>" />
          <input name="button" type="button" onclick="ValidarUsr(this.form)" value="Guardar" /></td>
    </tr>
  </table>
</form>
<p>&nbsp;</p>
<p>
  
  <?php    
        
} elseif ($mod == 'pass' || $accion == 'guardar'){
            
$pass1 $_POST['pass1'];
            
$password md5($pass1);
                
            
$consulta mysql_query("UPDATE usuarios SET password = '$password' WHERE id_usr = $id_usr LIMIT 1;"$link);
            
                        if (!
consulta){
                echo 
'<p aling="center"><strong>No se ha podido cambiar el password.</strong></p>
                <p aling="center">&nbsp;</p>
                <p aling="center">Revise las configuraciones o contáctese con el administrador.</p>
                <p aling="center">&nbsp;</p>
                <p aling="center"><a href="javascript:window.close()">Cerrar</a></p>'
;
            } else {
                echo 
'<p aling="center"><strong>El password ha sido modificado.</strong></p>
                <p aling="center">&nbsp;</p>
                <p aling="center"><a href="javascript:window.close()">Cerrar</a></p>'
;
            }

        } elseif (
$mod == 'pass' || $accion != 'guardar'){ ?>
</p>
<form id="form1" name="form1" method="post" action="usuario.php?mod=pass&amp;accion=guardar">
  <table width="350" border="0" cellspacing="3" cellpadding="0">
    <tr>
      <td colspan="2" class="subtitulos_inicio">Cambiar Contrase&ntilde;a </td>
    </tr>
    <tr>
      <td width="175" class="titulo_input">Nueva Contrase&ntilde;a</td>
      <td width="175" class="arriba"><input name="pass1" type="password" id="pass1" /></td>
    </tr>
    <tr>
      <td class="titulo_input">Repita nueva contrase&ntilde;a </td>
      <td class="arriba"><input name="pass2" type="password" id="pass2" /></td>
    </tr>
    <tr>
      <td colspan="2" align="center"><input name="nombre" type="hidden" id="nombre" value="<?php echo $row[4]; ?>" />
        <input name="apellido" type="hidden" id="apellido" value="<?php echo $row[5]; ?>" />
        <input name="email" type="hidden" id="email" value="<?php echo $row[6]; ?>" />
      <input name="button2" type="button" onclick="ValidarUsr(this.form)" value="Guardar" /></td>
    </tr>
  </table>
</form>
<p>&nbsp;</p>
<p>
  
  <?php
        
}
    }
}
?>
</p>
</body>
</html>


gracias!!

Phaq!*
  #2 (permalink)  
Antiguo 27/08/2008, 16:36
 
Fecha de Ingreso: agosto-2008
Mensajes: 32
Antigüedad: 15 años, 8 meses
Puntos: 1
Respuesta: Parse error: syntax error, unexpected $end

Hola, así a bote pronto tienes un error con una variable (te falta el $):

if (!$consulta) {
echo '<p aling="center"><strong>No se ha podido editar el usuario.</strong></p>
....

Y más abajo también se repite:

if (!$consulta) {
echo '<p aling="center"><strong>No se ha podido cambiar el password.</strong></p>
....

Y una cosa más, no es aling, sino align :P
  #3 (permalink)  
Antiguo 27/08/2008, 16:39
Avatar de masterojitos  
Fecha de Ingreso: julio-2008
Ubicación: Lima Callao Chucuito
Mensajes: 1.931
Antigüedad: 15 años, 9 meses
Puntos: 105
Respuesta: Parse error: syntax error, unexpected $end

Creo que tu error esta al declarar los hidden de los pass, ya que estas haciendo elseif despues de ya haber codigo html..... ummm no creo que sea correcta,,, mejor pregunta de nuevo un if sin el else...
tambien en la variable consulta, ya que noc si es una funcion (si lo fuera estaria bien) ya que debe ser la variable y debe llevar el $, despues el align que dijo el pata de arriba...... no tan importante claro....te dejo el codigo correcto:


Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Acciones de Usuario</title>
<link href="../estilos.css" rel="stylesheet" type="text/css" />
<script src="js.js"></script>
</head>
<body onUnload="opener.location.reload();">
<p>
  <?php
$mod 
$_GET['mod'];
$id_usr $_GET['id_usr'];
$accion $_GET['accion'];

include (
'config.php');

if (
$mod == 'eliminar'){
    
$res mysql_query("DELETE * FROM usuarios WHERE id_usr = $id_usr LIMIT 1;"$link);
    
    if (!
$res){
        echo 
'<p align="center"><strong>No se ha podido eliminar el usuario.</strong></p>
                <p align="center">&nbsp;</p>
                <p align="center">Revise las configuraciones o contáctese con el administrador.</p>
                <p align="center">&nbsp;</p>
                <p align="center"><a href="javascript:window.close()">Cerrar</a></p>'
;
    } else {
        echo 
'<p align="center"><strong>El usuario ha sido eliminado.</strong></p>
                <p align="center">&nbsp;</p>
                <p align="center"><a href="javascript:window.close()">Cerrar</a></p>'
;
    }
} else {
    
$res mysql_query("SELECT * FROM usuarios WHERE id_usr = $id_usr LIMIT 1;"$link);
    
    while (
$row myaql_fetch_row($res)){
        if (
$mod == 'editar' || $accion == 'guardar'){
            
$tipo_usr $_POST['tipo_usr'];
            
$nombre $_POST['nombre'];
            
$apellido $_POST['apellido'];
            
$email $_POST['email'];
                
            
$consulta mysql_query("UPDATE usuarios SET tipo_usr = '$tipo_usr', nombre = '$nombre', apellido = '$apellido', email = '$email' WHERE id_usr = $id_usr LIMIT 1;"$link);
            
            if (!
$consulta){
                echo 
'<p align="center"><strong>No se ha podido editar el usuario.</strong></p>
                <p align="center">&nbsp;</p>
                <p align="center">Revise las configuraciones o contáctese con el administrador.</p>
                <p align="center">&nbsp;</p>
                <p align="center"><a href="javascript:window.close()">Cerrar</a></p>'
;
            } else {
                echo 
'<p align="center"><strong>El usuario ha sido editado.</strong></p>
                <p align="center">&nbsp;</p>
                <p align="center"><a href="javascript:window.close()">Cerrar</a></p>'
;
            }
        } elseif (
$mod == 'editar' || $accion != 'guardar'){ ?>
</p>
<form id="form1" name="form1" method="post" action="usuario.php?mod=editar&amp;accion=guardar">
  <table width="350" border="0" cellspacing="3" cellpadding="0">
    <tr>
      <td colspan="2" class="subtitulos_inicio">Editar Usuario </td>
    </tr>
    <tr>
      <td width="175" class="titulo_input">Tipo de Usuario </td>
      <td width="175" class="arriba"><select name="tipo_usr" id="tipo_usr">
        <option value="empleado" <?php if ($row[1] == 'empleado'){ echo 'selected="selected"'; }?>>Empleado</option>
        <option value="admin" <?php if ($row[1] == 'admin'){ echo 'selected="selected"'; }?>>Administrador</option>
        <option value="cliente" <?php if ($row[1] == 'cliente'){ echo 'selected="selected"'; }?>>Cliente</option>
      </select>      </td>
    </tr>
    <tr>
      <td width="175" class="titulo_input">Nombre</td>
      <td width="175" class="arriba"><input name="nombre" type="text" id="nombre" value="<?php echo $row[4]; ?>" /></td>
    </tr>
    <tr>
      <td width="175" class="titulo_input">Apellido</td>
      <td width="175" class="arriba"><input name="apellido" type="text" id="apellido" value="<?php echo $row[5]; ?>" /></td>
    </tr>
    <tr>
      <td class="titulo_input">E-Mail</td>
      <td class="arriba"><input name="email" type="text" id="email" value="<?php echo $row[6]; ?>" /></td>
    </tr>
    <tr>
      <td colspan="2" align="center"><input name="usuario" type="hidden" id="usuario" value="<?php echo $row[2]; ?>" />
        <input name="pass1" type="hidden" id="pass1" value="<?php echo $row[3]; ?>" />
          <input name="pass2" type="hidden" id="pass2" value="<?php echo $row[3]; ?>" />
          <input name="button" type="button" onclick="ValidarUsr(this.form)" value="Guardar" /></td>
    </tr>
  </table>
</form>
<p>&nbsp;</p>
<p>
  
  <?php    
        
} elseif ($mod == 'pass' || $accion == 'guardar'){
            
$pass1 $_POST['pass1'];
            
$password md5($pass1);
                
            
$consulta mysql_query("UPDATE usuarios SET password = '$password' WHERE id_usr = $id_usr LIMIT 1;"$link);
            
                        if (!
$consulta){
                echo 
'<p align="center"><strong>No se ha podido cambiar el password.</strong></p>
                <p align="center">&nbsp;</p>
                <p align="center">Revise las configuraciones o contáctese con el administrador.</p>
                <p align="center">&nbsp;</p>
                <p align="center"><a href="javascript:window.close()">Cerrar</a></p>'
;
            } else {
                echo 
'<p align="center"><strong>El password ha sido modificado.</strong></p>
                <p align="center">&nbsp;</p>
                <p align="center"><a href="javascript:window.close()">Cerrar</a></p>'
;
            }

        } elseif (
$mod == 'pass' || $accion != 'guardar'){ ?>
</p>
<form id="form1" name="form1" method="post" action="usuario.php?mod=pass&amp;accion=guardar">
  <table width="350" border="0" cellspacing="3" cellpadding="0">
    <tr>
      <td colspan="2" class="subtitulos_inicio">Cambiar Contrase&ntilde;a </td>
    </tr>
    <tr>
      <td width="175" class="titulo_input">Nueva Contrase&ntilde;a</td>
      <td width="175" class="arriba"><input name="pass1" type="password" id="pass1" /></td>
    </tr>
    <tr>
      <td class="titulo_input">Repita nueva contrase&ntilde;a </td>
      <td class="arriba"><input name="pass2" type="password" id="pass2" /></td>
    </tr>
    <tr>
      <td colspan="2" align="center"><input name="nombre" type="hidden" id="nombre" value="<?php echo $row[4]; ?>" />
        <input name="apellido" type="hidden" id="apellido" value="<?php echo $row[5]; ?>" />
        <input name="email" type="hidden" id="email" value="<?php echo $row[6]; ?>" />
      <input name="button2" type="button" onclick="ValidarUsr(this.form)" value="Guardar" /></td>
    </tr>
  </table>
</form>
<p>&nbsp;</p>
<p>
  
  <?php
        
}
    }
}
?>
</p>
</body>
</html>
Espero te sirva....

Atte.

MAsterOjitos
  #4 (permalink)  
Antiguo 28/08/2008, 00:59
 
Fecha de Ingreso: agosto-2008
Mensajes: 218
Antigüedad: 15 años, 8 meses
Puntos: 7
Respuesta: Parse error: syntax error, unexpected $end

La estructuta que utilizas no es la más idónea, si abres un bloque php procura que todas las sentencias, funciones y operadores estén cerrados antes de finalizar el bloque de código.

Por decirte algo sobre el error en sí, a mí me ha pasado que tras tener todas las llaves bien colocadas seguia saliéndome el mismo error. Luego comprobé que se debía a que las líneas de código php tenían que comenzar al principio de línea. No sé por qué, pero era así.
  #5 (permalink)  
Antiguo 28/08/2008, 08:10
 
Fecha de Ingreso: agosto-2008
Mensajes: 20
Antigüedad: 15 años, 8 meses
Puntos: 0
Respuesta: Parse error: syntax error, unexpected $end

normalmente este tipo de error se debe a que te falta cerrar un parentesis o un '}' por algun lado... revisa cuidadosamente tu codigo
  #6 (permalink)  
Antiguo 30/11/2009, 13:26
 
Fecha de Ingreso: noviembre-2008
Mensajes: 2
Antigüedad: 15 años, 5 meses
Puntos: 0
Respuesta: Parse error: syntax error, unexpected $end

hola tengo un problema al instalar un plantilla en joomlan
me da este este erro: Parse error: syntax error, unexpected $end in C:\Program Files\EasyPHP5.2.10\www\webmaster\templates\jxtc_p olitical\js\modWidths.php on line 108

y cuando me fui a ese archivo este fue el codigo que me salio :

a ver si alguien al verlo me ayudma y me dice en donde esta el error de sintaxis

<script language="JavaScript" type="text/javascript">
jQuery(document).ready(function() {
jQuery = jQuery.noConflict();




// ModTitle Fixes
var modTitleWrapWidth = jQuery('#userOne .module .tick').width();
jQuery('#userOne .module .tick .modtitlewrap').width(modTitleWrapWidth).css("marg in", "0px auto");


var leftmodTitleWrapWidth = jQuery('#left .module .tick, #left .module .default').width();
jQuery('#left .module .tick .modtitlewrap, #left .module .default .modtitlewrap').width(leftmodTitleWrapWidth).css(" margin", "0px auto");


var rightmodTitleWrapWidth = jQuery('#right .module .tick, #right .module .default').width();
jQuery('#right .module .tick .modtitlewrap, #right .module .default .modtitlewrap').width(rightmodTitleWrapWidth).css( "margin", "0px auto");


jQuery('#maincontent div.usermodwrap:last-child, #bottomMods div.usermodwrap:last-child').css({padding:"0px"});

// User4 , User5, User6
/* var userFouruserFiveuserSixWidth = jQuery('#userFouruserFiveuserSix').width()/<?php echo $user4_user5_user6_count?>-60;
jQuery('#userFouruserFiveuserSix div.usermodwrap .usermod').width(userFouruserFiveuserSixWidth); */


<?php if($user4_user5_user6_count == 3) : ?>
jQuery('#userFouruserFiveuserSix div.usermodwrap:nth-child(0)').each(function(){
jQuery(this).css("width", "337px");
})
<?endif;?>

<?php if($user4_user5_user6_count == 2) : ?>
jQuery('#userFouruserFiveuserSix div.usermodwrap:nth-child(0)').each(function(){
jQuery(this).css("width", "60%");
})
jQuery('#userFouruserFiveuserSix div.usermodwrap:nth-child(1)').each(function(){
jQuery(this).css("width", "40%");
})
<?endif;?>

<?php if($user4_user5_user6_count == 1) : ?>
jQuery('#userFouruserFiveuserSix div.usermodwrap:nth-child(0)').each(function(){
jQuery(this).css("width", "100%");
})
<?endif;?>

jQuery('#userFouruserFiveuserSix div.usermodwrap:last').addClass("last");
jQuery('#userFouruserFiveuserSix div.usermodwrap').eq(1).addClass("second");

// bottomMods
var bottomModsWidth = jQuery('#bottomMods').width()/<?php echo $bottomMods_count?>-7.5;
jQuery('#bottomMods div.usermodwrap .usermod').width(bottomModsWidth);

jQuery('#bottomMods div.usermodwrap:nth-child(2)').css("float", "right");


jQuery('.module .centerH3').each(function() {
var centerH3Width = jQuery(this).children().children().width() + 21;
jQuery(this).width(centerH3Width).css("margin", "0px auto 12px auto");
jQuery(this).children().children().css("float", "none");
jQuery(this).children().css("float", "none");
});

jQuery('.module .tick .leftArrow, .module .default .leftArrow').each(function() {
var leftArrowWidth = jQuery(this).width();
var leftWrapWidth = jQuery(this).parent().parent().width() / - leftArrowWidth;
jQuery(this).width(leftArrowWidth);
jQuery(this).css({'margin' : '0px 0px 0px ' + leftWrapWidth + 'px'});
jQuery(this).parent().width(leftArrowWidth);
});




});

jQuery(window).load(function() {
jQuery = jQuery.noConflict();

// Right Column Height
var contentHeight = jQuery('#content').height();
var rightColumnHeight = jQuery('#rightcolumn').height();
if(rightColumnHeight > contentHeight) {
contentHeight = rightColumnHeight;
jQuery('#rightcolumn').height(rightColumnHeight);
}
else {
jQuery('#rightcolumn').height(contentHeight);
}


if(jQuery.browser.msie && parseInt(jQuery.browser.version) <= 7) {
var docHeight2 = jQuery("body").height();
}
else {
var docHeight2 = jQuery(document).height();

}
jQuery('#footerBG').css("top", docHeight2 + "px").css("position", "absolute");

});




</script>

gracias.

att: methoner
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 06:12.