Jump to content

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


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>
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.