• 0

Help with PHP script


Question

Is there any reason why this PHP script isn't working.

It's supposed to grab event dates from the vbulletin calendar. It connects to the database fine and returns no errors. but it doesn't display any events.

I'm not really understand the value 86400 and 54000 in the date vars.

Any ideas?

Thanks

<?php

$host   = "localhost"; // Host
$dbUser = "----------";   // Username
$dbPass = "--------";  // Password
$db   = "-------------";	 // Database

mysql_connect("$host", "$dbUser", "$dbPass") or die(mysql_error());
mysql_select_db("$db") or die(mysql_error());

$time_now = time();
$day_before = $time_now - 86400;

echo "<p><b>Upcoming Events</b></p>";
echo "<p>Click event title for more details</p>";
$result = mysql_query ("SELECT dateline, dateline_from, eventid, title FROM event WHERE calendarid = 1 AND dateline_from >= '$day_before' ORDER BY dateline_from LIMIT 10"); 

while($row = mysql_fetch_array( $result )) {	
echo "<p>". date("l - d M Y", $row['dateline_from']+54000)." - <a href='/forum/calendar.php?do=getinfo&e=" . $row['eventid'] . "&c=1'>". $row['title'] . "</a></p>";
}

?>

Link to comment
https://www.neowin.net/forum/topic/855274-help-with-php-script/
Share on other sites

1 answer to this question

Recommended Posts

  • 0

I'm not sure why it isn't working - are you sure you have events in the calendar?

The 86400 and 54000 are time in seconds and are used as offsets by the script.

PHP's date and time functions work according to the Unix clock/calendar method where time starts at Jan 1, 1970 00:00:00 and it counts up from there in seconds to generate a date.

The $day_before takes today's time and subtracts 24 hours (86400 seconds) to get the day before.

The 54000 equates to 15 hours, but I'm not sure why it is adding that to the date retrieved from the database unless it is used as an offset based on your forum's timezone setting.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.