Ver Mensaje Individual
  #1 (permalink)  
Antiguo 24/01/2013, 05:29
dfgphp
 
Fecha de Ingreso: diciembre-2011
Ubicación: pontevedra
Mensajes: 17
Antigüedad: 12 años, 5 meses
Puntos: 0
ERROR con MYSQL_ASSOC

Tengo un error y queria saber si esta bien formulado el programa? Gracias

ERROR:

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\web\test_clase.php on line 37

Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\web\test_clase.php on line 72

PROGRAMA

Código PHP:
Ver original
  1. <?php
  2.     include('include/opendbase.php');
  3.     // ----------------------- LEE CLASES --------------------------------------
  4.     $consulta   = "SELECT * FROM `clases`
  5.                            WHERE clase = '$clase'
  6.                            ";
  7.    
  8.     $salida = mysql_query($consulta, $coneccion);  
  9.     $row    = mysql_fetch_array($salida,MYSQL_ASSOC);
  10.    
  11.     $Id_TipoC = $row['idTC'];
  12.  
  13.     // ---------------------- LEE TEST -----------------------------------------
  14.    
  15.     $consulta   = "SELECT * FROM `tests`
  16.                            WHERE Id_TipoC = '$Id_TipoC'
  17.                            AND   CodiTest = '$testNumero'
  18.                            ";
  19.    
  20.     $salida = mysql_query($consulta, $coneccion);  
  21.     $row    = mysql_fetch_array($salida,MYSQL_ASSOC);
  22.    
  23.     $IdTest         = $row['Id'];
  24.     $NumRespostes   = $row['NumRespostes'];
  25.                        
  26.     /// ---------------------- LEE Preguntas -------------------------------------
  27.     $consulta   = "SELECT *
  28.                                 FROM  tests_preguntes, preguntes
  29.                                 WHERE tests_preguntes.Id_Test     = $IdTest                              
  30.                   AND   tests_preguntes.Id_Pregunta = Preguntes.Id                         
  31.                                 ORDER BY Posicio";
  32.                                        
  33.     $salida = mysql_query($consulta, $coneccion);  
  34.     // echo $consulta.'<br>';
  35.    
  36.     $indAux = 1;
  37.     while($row = mysql_fetch_array($salida, MYSQL_ASSOC)) {
  38.         $id = $indAux;
  39.     // $row['id'];  
  40.        
  41.         $pregunta[$id]['id']            = $id;
  42.         $pregunta[$id]['Posicio']       = $row['Posicio'];
  43.         $pregunta[$id]['Pregunta']      = $row['Pregunta'];
  44.         $pregunta[$id]['Resp1']         = $row['Resp1'];
  45.         $pregunta[$id]['Resp2']         = $row['Resp2'];
  46.         $pregunta[$id]['Resp3']         = $row['Resp3'];
  47.         $pregunta[$id]['Resp4']         = $row['Resp4'];
  48.         $pregunta[$id]['RespCorrecta']  = $row['RespCorrecta'];
  49.         $pregunta[$id]['FotoPreg']      = $row['FotoPreg'];
  50.         $indAux++;         
  51.     }
  52.      
  53.     echo '<input type="hidden" id="preguntaActual"  value="1" />';
  54.        
  55.  
  56.     $titulo         = 'Test Nro '.$testNumero;
  57.    
  58.     echo '<div class="btnVarios" >';
  59.         echo '<h2 style="color:#009900;" >'.$titulo.'</h2>';
  60.     echo '</div>';
  61.     echo '<hr class="oculto" />';        
  62.    
  63.    
  64.     if ($mostrarTest == 1) {
  65.        
  66.         $_SESSION['numero']  = $testNumero;
  67.         $_SESSION['clase']   = $clase;
  68.         $auxPreg = 0;
  69.        
  70.         echo '<form name="formTest" method="post" action="evaluacion_test.html" >';
  71.         echo '<input type="hidden" name="evaluar" value="1" />';
  72.         foreach($pregunta as $pregId => $fila) {
  73.             if ($pregId == 1) { $display = 'block'; } else { $display = 'none'; }