I can not find the error: Parse error:

-1

Hello I get this error and I can not find it wrong

  

Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE),   expecting identifier (T_STRING) or variable (T_VARIABLE) or number   (T_NUM_STRING) in   C: \ xampp \ htdocs \ SIE \ Extras \ \ Extras_list.php on line 154

Code:

 echo "<button  class=\"btn btn-info\" id=\"editarConsulta\" onclick=\"cambiarContenidos('#contenidos','HorasExtras/edita_horasextras.php?accion=editar&id=<?php echo $rowActividades['Id_horasextras']; ?>' );\">";
    
asked by carlos becerra 03.10.2018 в 22:08
source

1 answer

1

Instead of writing a code that really hurts the eye and that will cause headaches to analyze it, you can use variables, for example:

id=$rowActividades['Id_horasextras'];
$onClick="onclick=\"cambiarContenidos('#contenidos','HorasExtras/edita_horasextras.php?accion=editar&id=$id' );\"";

echo "<button  class=\"btn btn-info\" id=\"editarConsulta\" $onClick>";

Exit:

<button  class="btn btn-info" id="editarConsulta" onclick="cambiarContenidos('#contenidos','HorasExtras/edita_horasextras.php?accion=editar&id=1' );">

That way:

  • the code is clear and more elegant
  • you have the $id available if you need it
  • you have the $onClick available also if you need it later

NOTE: It may be appropriate to text the button ....

    
answered by 03.10.2018 / 22:28
source