[thelist] simple (?) php question
Duncan O'Neill
dbaxo at ihug.co.nz
Sat Aug 17 05:45:01 CDT 2002
Andrew Maynes wrote:
> can you post the code that is pulling the records?
>
here's the code in its entirety. Copied and pasted, so
wraps may be wray. The most pertinent lines are these;
<h2><? print($row["heading"]); ?></h2>
<? print($row["storyText"]); ?>
thanks for any help you can offer.
<?
// connect to database
if (!@mysql_connect("localhost","*****","*******")){
echo("<p>Unable to connect to the database server at this time</p>");
}
//select the rumours table
if (!@mysql_select_db("dbo")){
echo("<p>Unable to connect to the rumours database at this
time</p>");
}
//select a random value in case the story variable has not been set
if (!isset($story)){
$storyIds = mysql_query("SELECT storyId from rumours");
$stories = array();
$j=0;
while ($row_rand=mysql_fetch_array($storyIds)){
$stories[$j] = $row_rand["storyId"]; $j++;
}
$story = $stories[rand(0,$j-1)];
}
// now get the chosen story information out of the db
$result = mysql_query("SELECT heading,plugline,storyText from rumours
WHERE storyId='$story'");
if(!$result){
echo("<p>Unable to connect to the rumours database at this time</p>");
exit();
}
$row=mysql_fetch_array($result);
// Inlcude all information down to the H2 tag
if (!@require_once("header.html")){
print("<html><head><title>Rumours | The Urban Legend
magazine</title>" .
"</head><body><h2>Error</h2><a href='rumours.php'>Try Again</a> or <a
href='http://homepages.ihug.co.nz/~dbaxo/'>back to The Urban Legend
magazine</a>");
}
?>
<h2><? print($row["heading"]); ?></h2>
<? print($row["storyText"]); ?>
<p class="copyright">© Carl Wyant</p>
<?
//footnote bottom links and hitbox
if (!@require_once("footer.html")){
print("</body></html>");
}
--
=====================================================
Duncan O'Neill
"Smith The Reporter"
http://homepages.ihug.co.nz/~dbaxo/urban_legend.htm
=====================================================
More information about the thelist
mailing list