Quiero que alguien me corrija este código de php
<?php
function conecta()
{
#Conectamos con MySQL
echo "
<p>
<h3>Pruebas con Bases de Datos: </h3>
</p>
";
echo "
<table border='0' width='100%'>
<tr>
<td width='75%'><font size='5'>$bd</font></td>
<td><a href='/b2b/mysqlconten.php?tabla=cliente'>Lista de clientes</a></td>
</tr>
</table>
";
$bd = mysql_connect("localhost","mysqladmin","mysqladmin");
if (!$bd)
die ("
<h3>***Fallo en el establecimiento de la conexión***</h3>
");
#Seleccionamos la base de datos a utilizar
if (!mysql_select_db("/b2b/mysqlconten.php?tabla=cliente", $bd))
die("
<h3>****Error en la selección de la base de datos****</h3>
".mysql_errno());
#Efectuamos la consulta SQL
$sql ="select cdg, descripcion, poblacion, from cliente where poblacion=plasencia";
$resultado=mysql_query($sql,$link);
if(!mysql_query($sql,$link))
die("Error en la consulta SQL");
?>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<th width="5%">Código</th>
<th width="7%">Descripción</th>
<th width="5%">Población</th>
</tr>
</table>
<?php
//Hacemos un bucle para que tome los datos:
while($row=mysql_fetch_array($resultado))
{
echo "
<table width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td align=\"center\" width=\"5%\" nowrap=\"nowrap\">$row[cdg]</td>
<td align=\"center\" width=\"7%\">$row[descripcion]</td>
<td align=\"center\" width=\"5%\">$row[poblacion]</td>
</tr>
</table>
";
}
mysql_free_result($resultado);
mysql_close($link);
#Mostramos los resultados obtenidos
while( $row = mysql_fetch_array ( $resultado ))
{
echo $row [ "cdg" ];
echo $row [ "descripcion" ];
echo $row [ "poblacion" ];
}
return $bd;
#Cerramos la conexión con la base de datos
mysql_close($conexion);
}
conecta();
?>
function conecta()
{
#Conectamos con MySQL
echo "
<p>
<h3>Pruebas con Bases de Datos: </h3>
</p>
";
echo "
<table border='0' width='100%'>
<tr>
<td width='75%'><font size='5'>$bd</font></td>
<td><a href='/b2b/mysqlconten.php?tabla=cliente'>Lista de clientes</a></td>
</tr>
</table>
";
$bd = mysql_connect("localhost","mysqladmin","mysqladmin");
if (!$bd)
die ("
<h3>***Fallo en el establecimiento de la conexión***</h3>
");
#Seleccionamos la base de datos a utilizar
if (!mysql_select_db("/b2b/mysqlconten.php?tabla=cliente", $bd))
die("
<h3>****Error en la selección de la base de datos****</h3>
".mysql_errno());
#Efectuamos la consulta SQL
$sql ="select cdg, descripcion, poblacion, from cliente where poblacion=plasencia";
$resultado=mysql_query($sql,$link);
if(!mysql_query($sql,$link))
die("Error en la consulta SQL");
?>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<th width="5%">Código</th>
<th width="7%">Descripción</th>
<th width="5%">Población</th>
</tr>
</table>
<?php
//Hacemos un bucle para que tome los datos:
while($row=mysql_fetch_array($resultado))
{
echo "
<table width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td align=\"center\" width=\"5%\" nowrap=\"nowrap\">$row[cdg]</td>
<td align=\"center\" width=\"7%\">$row[descripcion]</td>
<td align=\"center\" width=\"5%\">$row[poblacion]</td>
</tr>
</table>
";
}
mysql_free_result($resultado);
mysql_close($link);
#Mostramos los resultados obtenidos
while( $row = mysql_fetch_array ( $resultado ))
{
echo $row [ "cdg" ];
echo $row [ "descripcion" ];
echo $row [ "poblacion" ];
}
return $bd;
#Cerramos la conexión con la base de datos
mysql_close($conexion);
}
conecta();
?>
1 respuesta
Respuesta de Chari Saiz
1