Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/07/2009, 15:22
Avatar de yoyoyo82
yoyoyo82
 
Fecha de Ingreso: julio-2009
Ubicación: Springfield
Mensajes: 159
Antigüedad: 14 años, 9 meses
Puntos: 1
Problema con consulta en php

Hola amigos tengo un problema al unir dos tablas en mysql y que me lo muestre en una pagina en php este es el codigo
<?
//Conexion con la base
mysql_connect("localhost","root","yoyoyo");

//Ejecutamos la sentencia SQL
$result=mysql_db_query("prep","select matricula,nombre,apaterno,amaterno,mat_1,cal_1,cal _2,prom_1 from t_alumnos join t_calificaciones (on t_calificaciones.matricula=t_alumnos.matricula) where matricula='1528'");
?>
<table width="4220" height="64" border="1" align="center">
<tr>
<th width="68" height="58" >Matrícula</th>
<th width="43">Nombre</th>
<th width="40">A. Paterno</th>
<th width="660" >A. Materno</th>
<th width="660" >Materia 1</th>
<th width="41">cal_1</th>
<th width="41">cal_2</th>
<th width="360">prom_1</th>


</tr>

<?
//Mostramos los registros
while ($row=mysql_fetch_array($result))
{
echo '<tr><td>'.$row["matricula"].'</td>';
echo '<td>'.$row["nombre"].'</td>';
echo '<td>'.$row["apaterno"].'</td>';
echo '<td>'.$row["amaterno"].'</td>';
echo '<td>'.$row["mat_1"].'</td>';
echo '<td>'.$row["cal_1"].'</td>';
echo '<td>'.$row["cal_2"].'</td>';
echo '<td>'.$row["prom_1"].'</td></tr>';


}

mysql_free_result($result) ?>
</table>
las tablas y los registros ya existen en ambas tablas y matricula es la clave principal en las 2 tablas me manda el siguiente error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\php\Prepa\Vespertino\Primero\Grupo 1\materia.php on line 40
while ($row=mysql_fetch_array($result))
Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\php\Prepa\Vespertino\Primero\Grupo 1\materia.php on line 54
mysql_free_result($result)
*cuando hago la consulta sobre una sola tabla si me muestra los datos gracias