Nedenstående script udskriver navnet på alle tabeller og deres records, som forefindes i din database.
<?PHP
mysql_connect(....dine vars...) or die("couldn't connect to server");
$dbname = "name_of_database";
$result = mysql_list_tables($dbname) or die("couldn't connect to database");
while ($row = mysql_fetch_row($result)) {
print "Table: $row[0]";
$fields = mysql_list_fields($dbname, $row[0]);
$columns = mysql_num_fields($fields);
for ($i = 0; $i < $columns; $i++) {
echo "Record: " . mysql_field_name($fields, $i) . "";
}
print "";
}
?>
Det burde fortælle dig om det er noget galt med dit query....
Får den her:
Table: tagwall
Record: navn
Record: mail
Record: website
Record: overskrift
Record: tekst
Record: dato
Der er vel ingen fejl ?
Selve min fil ser sådan her ud:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<?PHP
$connection = mysql_connect("localhost","","") or die("Couldn't connect to databaseserver");
mysql_select_db("", $connection) or die("Couldn't connect to database");
$query = "SELECT * FROM tagwall ORDER BY id";
$result = mysql_query($query, $connection) or die ("Couldn't complete query");
echo "<font color=\\"red\\"><ol>";
while($r = mysql_fetch_array($result)) {
mysql_close($connection);
$navn = $r["navn"];
$mail = $r["mail"];
$website = $r["website"];
$overskrift = $r["overskrift"];
$tekst = $r["tekst"];
$dato = $r["dato"];
echo "<table width\\"500\\" border\\"1\\">";
echo "<tr>";
echo "<td width=\\"100\\">$navn</td>";
echo "<td width=\\"100\\">$mail</td>";
echo "<td width=\\"100\\">$website</td>";
echo "<td width=\\"100\\">$dato</td>";
echo "<tr>";
echo "<td width=\\"200\\" colspan=\\"3\\">$overskrift</td>";
echo "<td width=\\"200\\" colspan=\\"3\\">$tekst</td>";
echo "</tr>";
echo "</table>";
echo "</ol></font>";
}
?>
</body>
</html>
OG jeg har husket mit brugernavn, pass og database
Men den vil stadig ik virke...