elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Únete al Grupo Steam elhacker.NET


+  Foro de elhacker.net
|-+  Programación
| |-+  Desarrollo Web
| | |-+  PHP (Moderador: #!drvy)
| | | |-+  My sqli echo parse error
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: My sqli echo parse error  (Leído 2,154 veces)
percentil101

Desconectado Desconectado

Mensajes: 13


Ver Perfil
My sqli echo parse error
« en: 6 Septiembre 2019, 08:49 am »

Hola dónde está lo que estoy haciendo mal? ME podéis ayudar por favor a ver qué pudo modificar?

Parse error: syntax error, unexpected 'echo' (T_ECHO) in C:\xampp\htdocs\delos\materialvisitas.php on line 190

Código
  1.  
  2.  
  3. <?php  
  4. $conexio=mysqli_connect("localhost","root","") or die("Problemas en la conexion");
  5. mysqli_select_db($conexio,"ugtdef") or die("Problemas en la seleccin de la base de datos");  
  6.  
  7.  
  8.  
  9. ?>
  10. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  11. <?php
  12.  
  13.  $result=$conexio->query("SELECT * FROM materialvisitas ORDER BY fecha DESC");  
  14.  
  15. ?>
  16.  
  17.  
  18. <table class="table table-condensed table-hover table-bordered table-striped text-justify">
  19. <tr><td colspan="5"><strong> Material Ordenado Por Fecha (Working Progress)</strong></td></tr>
  20. <tr>
  21.  
  22.    <td><div class="sizef"><strong> Fecha Material</strong></div></td>
  23.     <td><strong> Archivo </strong></td>
  24.    <td><strong> Nombre </strong></td>
  25.    <td><strong> Nombre Largo</strong></td>
  26.  
  27. <td><strong> Descripci&oacute;n y observaciones</strong></td>
  28.  
  29.  
  30.  
  31.                    </tr>
  32.  
  33.               <?php  
  34.  
  35.  
  36. while ($row=$result->fetch_array(MYSQLI_ASSOC){  
  37.  
  38.  echo "</tr>";
  39. echo "<td>$row[1]</td>";
  40.  echo "<td>$row[2]</td>";
  41.  
  42. echo "<td><a href=$row[5]>Descargar Fichero</a></td>";
  43.    echo "<td>$row[2]</td>";  
  44.    echo "<td>$row[3]</td>";  
  45.  
  46.  //echo "<td >$row[4]</td>";
  47.  
  48.  
  49.  
  50.    echo "</tr>";  
  51.  
  52.    $result->free;
  53. }  else {
  54.   exit($mysqli -> error); // this will show the error (if exists)
  55. }
  56.  
  57. ?>  
  58. </table>                    
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69. </div>
  70. </div>
  71.  



Mod: Temas sobre PHP van al subforo de PHP.


« Última modificación: 6 Septiembre 2019, 09:23 am por #!drvy » En línea

#!drvy
Moderador
***
Desconectado Desconectado

Mensajes: 5.850



Ver Perfil WWW
Re: My sqli echo parse error
« Respuesta #1 en: 6 Septiembre 2019, 09:25 am »

Cual es la línea 190?


Saludos


En línea

percentil101

Desconectado Desconectado

Mensajes: 13


Ver Perfil
Re: My sqli echo parse error
« Respuesta #2 en: 6 Septiembre 2019, 13:36 pm »

Es esta parte a partir del primer echo:

Código
  1.  
  2. while ($row=$result->fetch_array(MYSQLI_ASSOC){  
  3.  
  4.  echo "</tr>";
  5. echo "<td>$row[1]</td>";
  6.  echo "<td>$row[2]</td>";
  7.  
  8. echo "<td><a href=$row[5]>Descargar Fichero</a></td>";
  9.    echo "<td>$row[2]</td>";  
  10.    echo "<td>$row[3]</td>";  
  11.  
  12.  //echo "<td >$row[4]</td>";
  13.  
  14.  
  15.  
  16.    echo "</tr>";  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  

Añadi esto (    $result->free;) pero vamos el error se detiene aquí en el primer echo del código.
En línea

#!drvy
Moderador
***
Desconectado Desconectado

Mensajes: 5.850



Ver Perfil WWW
Re: My sqli echo parse error
« Respuesta #3 en: 6 Septiembre 2019, 14:06 pm »

Te falta cerrar el while.

Código
  1. while($row = $result->fetch_array(MYSQLI_ASSOC)) {


PD: Cuando te dice que no esperaba algo en X línea, es que en las líneas previas hay algún fallo.

Saludos
« Última modificación: 6 Septiembre 2019, 14:12 pm por #!drvy » En línea

percentil101

Desconectado Desconectado

Mensajes: 13


Ver Perfil
Re: My sqli echo parse error
« Respuesta #4 en: 6 Septiembre 2019, 16:18 pm »

Sí es verdad lo he copiado mal pero con el paréntesis me sale este error:

Fatal error: Uncaught Error: Call to a member function fetch_array() on bool in C:\xampp\htdocs\delegados\materialvisitas.php:186 Stack trace: #0 {main}thrown in C:\xampp\htdocs\delegados\materialvisitas.php on line 186

La línea 186 es
Código
  1. while ($row=$result->fetch_array(MYSQLI_ASSOC)){


Este es el código entero:

Código
  1.  
  2.  
  3.   <div class="col-lg-12 ">
  4. <div class="table-responsive "  border="1" align="left">
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  <?php  
  18. $conexio=mysqli_connect("localhost","root","") or die("Problemas en la conexion");
  19. mysqli_select_db($conexio,"ugtdef") or die("Problemas en la seleccin de la base de datos");  
  20.  
  21.  
  22.  
  23. ?>
  24. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  25. <?php
  26.  
  27.  $result=$conexio->query("SELECT * FROM materialvisitas ORDER BY fecha DESC");  
  28.  
  29. ?>
  30.  
  31.  
  32. <table class="table table-condensed table-hover table-bordered table-striped text-justify">
  33. <tr><td colspan="5"><strong> Material Ordenado Por Fecha (Working Progress)</strong></td></tr>
  34. <tr>
  35.  
  36.    <td><div class="sizef"><strong> Fecha Material</strong></div></td>
  37.     <td><strong> Archivo </strong></td>
  38.    <td><strong> Nombre </strong></td>
  39.    <td><strong> Nombre Largo</strong></td>
  40.  
  41. <td><strong> Descripci&oacute;n y observaciones</strong></td>
  42.  
  43.  
  44.  
  45.                    </tr>
  46.  
  47.               <?php  
  48.  
  49.  
  50. while ($row=$result->fetch_array(MYSQLI_ASSOC)){  
  51.  
  52.  echo "</tr>";
  53.  
  54.  echo "<td>$row[2]</td>";
  55.  
  56. echo "<td><a href=$row[5]>Descargar Fichero</a></td>";
  57.    echo "<td>$row[2]</td>";  
  58.    echo "<td>$row[3]</td>";  
  59.  
  60.  echo "<td >$row[4]</td>";
  61.  
  62.  
  63.  
  64.    echo "</tr>";  
  65.  
  66.  }  
  67.  
  68. ?>  
  69.  
  70. </table>                    
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines