surfmad74
-
Posts
8 -
Joined
-
Last visited
Posts posted by surfmad74
-
-
In the database the date is stored like so...
posted_on
2012-04-18 18:29:15
Below is the code from the page 'forum.php'
<?php # Script 15.4 - forum.php // This page shows the threads in a forum. include ('includes/header.html'); // Retrieve all the messages in this forum... // If the user is logged in and has chosen a time zone, // use that to convert the dates and times: if (isset($_SESSION['user_tz'])) { $first = "CONVERT_TZ(p.posted_on, 'UTC', '{$_SESSION['user_tz']}')"; $last = "CONVERT_TZ(p.posted_on, 'UTC', '{$_SESSION['user_tz']}')"; } else { $first = 'p.posted_on'; $last = 'p.posted_on'; } // The query for retrieving all the threads in this forum, along with the original user, // when the thread was first posted, when it was last replied to, and how many replies it's had: $q = "SELECT t.thread_id, t.subject, username, COUNT(post_id) - 1 AS responses, MAX(DATE_FORMAT($last, '%e-%b-%y %l:%i %p')) AS last, MIN(DATE_FORMAT($first, '%e-%b-%y %l:%i %p')) AS first FROM threads AS t INNER JOIN posts AS p USING (thread_id) INNER JOIN users AS u ON t.user_id = u.user_id WHERE t.lang_id = {$_SESSION['lid']} GROUP BY (p.thread_id) ORDER BY last DESC"; $r = mysqli_query($dbc, $q); if (mysqli_num_rows($r) > 0) { // Create a table: echo '<table width="100%" border="0" cellspacing="2" cellpadding="2" align="center"> <tr> <td align="left" width="50%"><em>' . $words['subject'] . '</em>:</td> <td align="left" width="20%"><em>' . $words['posted_by'] . '</em>:</td> <td align="center" width="10%"><em>' . $words['posted_on'] . '</em>:</td> <td align="center" width="10%"><em>' . $words['replies'] . '</em>:</td> <td align="center" width="10%"><em>' . $words['latest_reply'] . '</em>:</td> </tr>'; // Fetch each thread: while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) { echo '<tr> <td align="left"><a href="read.php?tid=' . $row['thread_id'] . '">' . $row['subject'] . '</a></td> <td align="left">' . $row['username'] . '</td> <td align="center">' . $row['first'] . '</td> <td align="center">' . $row['responses'] . '</td> <td align="center">' . $row['last'] . '</td> </tr>'; } echo '</table>'; // Complete the table. } else { echo '<p>There are currently no messages in this forum.</p>'; } // Include the HTML footer file: include ('includes/footer.html'); ?>
-
HartleySan.... that worked!
I received
Fri, 20 Apr 2012 13:43:06 +0100Array
( [seconds] => 6 [minutes] => 43 [hours] => 13 [mday] => 20 [wday] => 5 [mon] => 4 [year] => 2012 [yday] => 110 [weekday] => Friday [month] => April [0] => 1334925786 )
So what can II try next?
thanks for your help!!!
-
Hi I've created the Message Board site as per the book but for some reason the Date & Time on both the Forum.php and read.php page aren't displaying.
I've tried the supplied code as well as my own and neither work so I'm assuming it might be a php setting or MySQL setting?
I've run the site using XAMPP on my MacOSX and also on my rented server.
I don't know if it makes any difference but the php.ini file timezone is set to...
date.timezone = "Europe/London"
Can you help please, many thanks
Grant
-
I'm not too sure what edition it is but it was published December 2007 so I guess maybe its the third edition?
Shall I repost?
-
Hi I've created the Message Board site as per the book but for some reason the Date & Time on both the Forum.php and read.php page aren't displaying.
I've tried the supplied code as well as my own and neither work so I'm assuming it might be a php setting or MySQL setting?
I've run the site using XAMPP on my MacOSX and also on my rented server.
I don't know if it makes any difference but the php.ini file timezone is set to...
date.timezone = "Europe/London"
Can you help please, many thanks
Grant
-
Hi I fixed the problem and your right.
It wasn't a space as such causing the problem, I included a comment on mysqli_connect.php before the opening <?php tag as soon as I removed it the page worked.
thanks for your help!
-
I'm working through Larry's PhP 6 and MySqL 5 book which so far has been excellent but I've hit a snag I can't get past.
On Chapter 11 'Cookies & Sessions'
I've completed page 327 - 339 and when I test my pages on my MacOSX running Xampp I get errors shown below.
Warning: Cannot modify header information - headers already sent by (output started at /Applications/XAMPP/xamppfiles/htdocs/php/mysqli_connect.php:4) in /Applications/XAMPP/xamppfiles/htdocs/php/ch11/login.php on line 23
Warning: Cannot modify header information - headers already sent by (output started at /Applications/XAMPP/xamppfiles/htdocs/php/mysqli_connect.php:4) in /Applications/XAMPP/xamppfiles/htdocs/php/ch11/login.php on line 24
Warning: Cannot modify header information - headers already sent by (output started at /Applications/XAMPP/xamppfiles/htdocs/php/mysqli_connect.php:4) in /Applications/XAMPP/xamppfiles/htdocs/php/ch11/login.php on line 28
I've checked the code and removed all the spaces after the final ?> php tag but I still get the error.
Could you help please, many thanks in advance.
Below is the code on 'Login.php'
Line 23/24 is the setcookie function
Line 28 is the header function
<?php # Script 9.3 - login.php // This page processes the login form submission. // Upon successful login, the user is redirected. // Two included files are necessary. // Send NOTHING to the Web browser prior to the setcookie() lines! // Check if the form has been submitted: if (isset($_POST['submitted'])) { // For processing the login: require_once ('includes/login_functions.inc.php'); // Need the database connection: require_once ('../mysqli_connect.php'); // Check the login: list ($check, $data) = check_login($dbc, $_POST['email'], $_POST['pass']); if ($check) { // OK! // Set the cookies: setcookie ('user_id', $data['user_id']); setcookie ('first_name', $data['first_name']); // Redirect: $url = absolute_url ('loggedin.php'); header("Location:$url"); exit(); // Quit the script. } else { // Unsuccessful! // Assign $data to $errors for error reporting // in the login_page.inc.php file. $errors = $data; } mysqli_close($dbc); // Close the database connection. } // End of the main submit conditional. // Create the page: include ('includes/login_page.inc.php'); ?>
Date & Time Not Displaying On Forum.Php & Read.Php Page
in PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide (3rd Edition)
Posted
So if I add to the php.ini file the other timezones that should work?
Like so?
date.timezone = "Europe/London"
date.timezone = "America/New_York"
etc