Forgive me in advance if this is hard to follow. I know I’ve been taking serious advantage of these boards and all of you fantastic people already. Wish I could have a programmer stand over my shoulder as a screw up!
[B]The Goal:
Enter a news item into a form that writes to a database (fields: id, date, headline, leadin, story). [COLOR=Red]check!
Auto-forward to a php script (makepage.php) which will auto-generate an html page based on ‘id’ and output ‘story’ (in a stylized page). [COLOR=Red]Not Quite check!
Display ‘date’, ‘headline’, ‘leadin’ on a separate page, and have ‘headline’ link to that url that was created in makepage.php. [COLOR=Red]Mostly check!
[B]The Problem:
I am able to generate that html page, and even get it to display the story from the database along with a headline, etc. But I get an error when I process my makepage.php. I think that I’ve just improvised code that happened to work occasionally.
[B]All Ready?
[code=php]<?php
$database=”newsadmin”;
$username=””;
$password=””;
mysql_connect(localhost,root);
@mysql_select_db($database) or die( “Unable to select database”);
$query=”select * from news ORDER BY ‘id’ DESC”;
$result=mysql_query($query);
$i=0;
while ($i < 1){
$id=mysql_result($result,$i,”id”);
$date=mysql_result($result,$i,”date”);
$headline=mysql_result($result,$i,”headline”);
$story=mysql_result($result,$i,”story”);
$selfgen=”news/$id.html”;
$filename=”$selfgen”;
$filehandler=fopen($filename, ‘w’) or die(“can’t open file”);
$stringData = “<body style=”background-color: #E8E8D0; font-family: arial, helvetica, sans-serif; font-size: 12px;
margin: 100px”>
<div style=”font-weight: bold; font-size: 14px”>$headline</div><br>
<div style=”font-weight: bold;”>$date</div><br>
$story</body>n”;
fwrite($filehandler,$stringData);
fclose($filehandler);
}
?>