I'm working on an interactive prayer board (this, BTW is a modified guestbook script) as part of a redo of my church's website and I've got everything running properly on it, such as getting entries into the database and I've got the profanity filter working like it should, and it's ALMOST ready for posting except for one weird problem I can't seem to figure out. In a couple of test entries I've made so far, on the timestamp, I'm getting weird times that are nowhere close to current. I've tried messing with the field type for the time in the database, such as timestamp vs. time vs. timedate, which yielded even strangER results. For some reason, the timestamp seems to insist on living in the not-too-distant past, as in last December and I can't figure out why. It's not giving me an error message or anything, it's just giving me any time (I even got the Unix epoch at one point, imagine that!) EXCEPT the correct time. How do I correct this?
Here's what I've got so far for a database setup according to PHPMyAdmin: Database name: westport (for Westport Community Church, St. Louis, MO) Table name: prayer -- and now the fields and the scoop on 'em: Fieldname number has a type of bigint(20), not null, auto-incrementing Fieldname name has a type of varchar(255), can be null Fieldname email has a type of varchar(255), can be null Fieldname location has a type of varchar(255), can be null Fieldname subject has a type of varchar(255), can be null Fieldname message has a type of text(no limit), can be null Fieldname time has a type of timestamp(14), can be null, default is 0000-00-00 00:00:00 And here's the code I've got so far on the page in question: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <!-- saved from url=(0030)http://www.westportchurch.com/ --> <html><head><title>Westport Community Church</title> <meta http-equiv=Content-Type content="text/html; charset=windows-1252"><!-- This site created with love by Fred McKinney (fredmck at fidnet dot com -- gotta keep myself safe from spammers, ya know!) --> <meta content="Westport Community Church" name=description> <LINK href="westport.css" type=text/css rel=stylesheet> </head><body> <?php include("header.inc"); ?> <table><tr valign="top"><td><?php include("menu.php"); ?></td> <td class="content" valign="top" cellpadding="5" width="100%"> Please take the time to pray for the requests below. Thank you.<br /><hr /> <?php $conn = mysql_connect("localhost","root",""); $select = mysql_select_db("westport"); $sql = mysql_query("select * from prayer") or die("SELECT Error: " . mysql_error() . " in Query: $sql"); $delete = mysql_query("delete * from prayer where to_days(NOW()) - to_days(date_col) > 90"); // the above line automatically deletes entries after 90 days, although those // who have requested prayer for something in their lives are more than // welcome to re-post if their prayer hasn't been answered by then $rs = mysql_query($sql, $conn); # Convert the MySQL internal timestamp to a more understandable format while ($row = mysql_fetch_array($sql)) { $datetime = $row["time"]; $year = substr($datetime, 0,4); $month = substr($datetime, 4,2); $day = substr($datetime, 6,2); $hour = substr($datetime, 8,2); $minute = substr($datetime, 10,2); $second = substr($datetime, 12,2); $orgdate = date("n/j/y @ g:i A ", mktime($hour, $minute, $second, $month, $day, $year)); ?> <table border="0" cellpadding="2" width="100%"><tr> <td class="database"> <?php if(($row["name"]) and ($row["email"])) { ?> <b>Name: </b><a href="mailto:<?php echo $row["email"] ?>"><?php echo $row["name"] ?></a></td> <?php } if((!$row["name"]) and ($row["email"])) { ?> <b>Name: </b><a href="mailto:<?php echo $row["email"] ?></a></td> <?php } if(($row["name"]) and (!$row["email"])) { ?> <b>Name: </b><?php echo $row["name"] ?></a></td> <?php } if((!$row["name"]) and (!$row["email"])) { ?> <b>Name: </b>(no name or E-mail address given)</td> <?php } ?> <td class="database" align="right" width="50%"><b>Location: </b> <?php if($row["location"]) { echo $row["location"] ?></td></tr> <?php } else { echo("(location not given)"); } ?> <tr> <td class="database"><b>Subject: </b> <?php if($row["subject"]) { echo $row["subject"] ?></td> <?php } else { echo("(subject not stated)"); } ?> <td class="database" align="right"><?php echo ("Posted on " . $orgdate . "CT"); ?></td></tr> <tr> <td class="content" colspan="2" width="100%"> <?php if($row["message"]) { echo $row["message"] ?></td></tr></table><hr /> <?php } else { echo("(unspoken prayer request)"); ?> </td></tr></table><hr /> <?php } } ?> </td></tr></table></body></html> For the record, I'm using the XAMPP for Linux (I have Mandrake PowerPack, BTW) bundle of Apache, MySQL, Perl, and PHP for a personal server program so I can test everything, plus it has PHPMyAdmin in it as part of the package and a few other goodies. That's all the relevant info I can think of pertaining to this situation. Does anyone know what could possibly be wrong here? Thanx in advance, Fred Community email addresses: Post message: [email protected] Subscribe: [EMAIL PROTECTED] Unsubscribe: [EMAIL PROTECTED] List owner: [EMAIL PROTECTED] Shortcut URL to this page: http://groups.yahoo.com/group/php-list Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/php-list/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
