Jump to content

Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in


btborges

Recommended Posts

how can I solve this

<?php
include('admin/panel/_setup.php');


?>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
    <meta charset="UTF-8">
	<title>Mis galerias</title>
	<link rel="stylesheet" href="website.css" />
</head>
<body>
    <div id="principal">
	      
<?php
if( isset( $_GET['gal'] ) ) {
    $id = $_GET['gal'];
	$consulta = "SELECT DESCRIPCION, TITULO FROM galerias WHERE IDGALERIA='$id'";
    $filas = mysqli_query($cnx, $consulta);
    $col = mysqli_fetch_assoc($filas);
    
	echo "<h2>$col[TITULO]</h2>";
	echo "<p>$col[DESCRIPCION]</p>";
	
	echo '<div id="ver_galeria">';
	$consulta = "SELECT * FROM FOTOS WHERE FKGALERIA='$id' AND ESTADO='visible' ORDER BY POSICION";
	$filas = mysqli_query($cnx, $consulta);
	while( $col = mysqli_fetch_assoc($filas)){
	echo '<div>';
	echo '<p>'.$col['NOMBRE'].'</p>';
	echo '<img src="admin/fotos/'.$col['ARCHIVO'].'" alt="'.$col['NOMBRE'].'" />';
	
	echo '</div>';
	
	
	}
	echo '</div>';

}else{
$consulta =<<<SQL
SELECT
     IDGALERIA,
	 TITULO,
	 DESCRIPCION,
	 DATE_FORMAT( FECHA_ALTA, '%d/%m/%y' ) FECHA
FROM
   galerias
ORDER BY
     FECHA_ALTA DESC
SQL;

$filas = mysqli_query( $cnx, $consulta );

echo '<div id="listado">';

while( $columna = mysqli_fetch_assoc($filas)){
      $id = $columna['IDGALERIA'];
      $subconsulta = "SELECT ARCHIVO FROM fotos WHERE FKGALERIA='$id' AND ESTADO='visible' ORDER BY RAND() LIMIT 1";
	  $filas2 = mysqli_query($cnx, $subconsulta);
	  $datos = mysqli_fetch_assoc($filas2);
	 
	  $nombre_archivo = $datos['ARCHIVO'];
	  
  echo '<div>';
   echo "<h2>$columna[TITULO]</h2>";
   echo "<div>$columna[FECHA]</div>";
   if( $nombre_archivo != null){
  echo "<img src='admin/fotos/$nombre_archivo' alt='preview de la galeria' />";
  }
   echo "<p>$columna[DESCRIPCION]</p>";
   echo "<a href='index.php?gal=$columna[IDGALERIA]'>VER GALERIA</a>";
   echo '</div>';
   }
    echo '</div>';
   
   }
   
   ?>
  </div>
 </body>
 </html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.