Ver Mensaje Individual
  #6 (permalink)  
Antiguo 22/05/2012, 11:14
Soyic
 
Fecha de Ingreso: enero-2012
Mensajes: 3
Antigüedad: 12 años, 3 meses
Puntos: 0
Respuesta: No me conecto a la base de datos

Ok si no me explique bien..... vuelvo a postear, esto es lo que me arroja no me ingresa ningun dato en la tabla.

Codigo para logearme.

<?php
$db_host='localhost';
$db_database='test';
$db_username='root';
$db_password='';
?>

Codigo de la tabla

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Displaying in an HTML table</title>
</head>
<body>
<table border="1">
<tr>
<th>Title</th>
<th>Author</th>
<th>Pages</th>
</tr>
<?php

//Include our login information
include('db_loging.php');

//Connect
$connection = mysql_connect('localhost', 'root', '');
if (!$connection) {
die("Could not connect to the database: <br />". mysql_error());
}

//Select the database
$db_select = mysql_select_db('test', $connection);
if (!$db_select) {
die("Could not select the database: <br />". mysql_error());
}

//Assing the query
$query = "SELECT * FROM books NATURAL JOIN authors";

//Excecute the query
$result = mysql_query($query);
if (!$result) {
die("Could not query the database: <br />". mysql_error());
}

//Fetch and display the results
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$title = $row["title"];
$author = $row["author"];
$pages = $row["pages"];
echo "<tr>";
echo "<td>$title</td>";
echo "<td>$author</td>";
echo "<td>$pages</td>";
echo "</tr>";

//Close connection
mysql_close($connection);
?>
</table>
</body>
</html>


Lo que me arroja:

". mysql_error()); } //Select the database $db_select = mysql_select_db('test', $connection); if (!$db_select) { die("Could not select the database:
". mysql_error()); } //Assing the query $query = "SELECT * FROM books NATURAL JOIN authors"; //Excecute the query $result = mysql_query($query); if (!$result) { die("Could not query the database:
". mysql_error()); } //Fetch and display the results while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $title = $row["title"]; $author = $row["author"]; $pages = $row["pages"]; echo ""; echo ""; echo ""; echo ""; echo ""; //Close connection mysql_close($connection); ?>
Title Author Pages
$title $author $pages

*** Aqui me anexa la tabla pero sin ningun dato***