Forum Moderators: coopster
I'm trying to display info from a database. It has 2 text columns, "Head" and "Story".
Here's the code (without the real password obv:):
<html>
<head></head>
<body>
<?php
$host = "localhost";
$user = "outpost_admin";
$pass = "pass";
$dbname = "test1";
$dbh=mysql_connect ("$host", "$user", "$pass") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("$dbname");
$sql = 'SELECT `news` . `Head` , `news` . `Story` '
. ' FROM news '
. ' ORDER BY `news` . `Head` ASC , `news` . `Story` ASC LIMIT 0, 30 ';
$query = mysql_query($sql);
while ($row = mysql_fetch_array($query)) {
echo "<p>",$row['Head'],": ",$row['Story'];
}
?>
</body>
When I load the page, all I see it this and nothing else:
",$row['Head'],": ",$row['Story']; }?>
Have a look HERE [webmasterworld.com]
Then go back to the top of the forum page and search our library; lots of goodies in there :)