Código PHP:
<?php
$conexion = mysql_connect('localhost', 'root', 'root');
mysql_select_db('pricipal',$conexion);
$query = "SELECT * FROM comentarios";
$resultado = mysql_query($query,$conexion) or die(mysql_error());
$total = mysql_num_rows($resultado);
?>
<head>
<meta http-equiv="Content-Type" content="Text//html;"/>
<title>Ejemplo De Conexion a MYSQL</totle>
</head>
<body>
<h1>Resultado</h1>
<?php
if($total>0)
{
while($file = mysql_fetch_assoc($resultado))
{
echo"<strong>". $fila['nombre']."</strong><br />";
echo"Email: ". $fila['email']."<br>";
echo"<strong>". $fila['comentario']."<br";
echo"Email: ". $fila['estado']."<br><br>";
}
}
?>
</html>
</body>
Código:
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: YES) in D:\AppServ\www\index.php on line 2 Warning: mysql_select_db() expects parameter 2 to be resource, boolean given in D:\AppServ\www\index.php on line 3 Warning: mysql_query() expects parameter 2 to be resource, boolean given in D:\AppServ\www\index.php on line 5 Access denied for user 'root'@'localhost' (using password: YES)