PDA

View Full Version : Calendar Events on Non-vB Pages


Caster
07-24-2004, 04:51 PM
Hey everyone, I'm having a little trouble with a script posted on this forum. Basically I just want show 1 calendar event (the script was to show 5) and jsut the title of the event and a link to it in the calendar page. Here is the code:

(sorry I forgot who posted it)

<?php BEGIN__VBULLETIN__CODE__SNIPPET

$events = $DB_site->query("select * from event order by dateline DESC limit 5");

if ($DB_site->num_rows($events))
{
while ($ev = $DB_site->fetch_array($events))
{
$news="";
$new_date = vbdate('Y.m.d', $ev['dateline'], false, false);
$news .= "<B>".$new_date."</B><BR>";
$news .= $ev['title']."<BR>";

echo "<A HREF=\"calendar.php?do=getinfo&e=$ev[eventid]&day=$new_date&c=1\">$news</A>";

}
}


?>

I'm having a little trouble trying to understand the script, what exactly is "BEGIN__VBULLETIN__CODE__SNIPPET" and to make the script work, I would have to select event, title, eventid, and dateline right?

Dark_Wizard
07-24-2004, 05:03 PM
Hey everyone, I'm having a little trouble with a script posted on this forum. Basically I just want show 1 calendar event (the script was to show 5) and jsut the title of the event and a link to it in the calendar page. Here is the code:

(sorry I forgot who posted it)

<?php BEGIN__VBULLETIN__CODE__SNIPPET

$events = $DB_site->query("select * from event order by dateline DESC limit 5");

if ($DB_site->num_rows($events))
{
while ($ev = $DB_site->fetch_array($events))
{
$news="";
$new_date = vbdate('Y.m.d', $ev['dateline'], false, false);
$news .= "<B>".$new_date."</B><BR>";
$news .= $ev['title']."<BR>";

echo "<A HREF=\"calendar.php?do=getinfo&e=$ev[eventid]&day=$new_date&c=1\">$news</A>";

}
}


?>

I'm having a little trouble trying to understand the script, what exactly is "BEGIN__VBULLETIN__CODE__SNIPPET" and to make the script work, I would have to select event, title, eventid, and dateline right?

Change this:

limit 5


to this:

limit 1


and disregard the "BEGIN__VBULLETIN__CODE__SNIPPET" as it's not needed.

And to just show the title...

change this:

$news="";
$new_date = vbdate('Y.m.d', $ev['dateline'], false, false);
$news .= "<B>".$new_date."</B><BR>";
$news .= $ev['title']."<BR>";


to this:

$news = $ev['title'];

Caster
07-24-2004, 05:10 PM
That was quick lol...

Thank you so much, going to try it out right now

Ok well I tried it out, and changed the script so it looks like...

<?
$connection = mysql_connect("localhost", "dbusername", "dbpass") or die("err");

mysql_select_db("db",$connection) or die ("err2");

$events = $DB_site->query("select * from event order by dateline DESC limit 1");

if ($DB_site->num_rows($events))
{
while ($ev = $DB_site->fetch_array($events))
{
$news = $ev['title'];

echo "<A HREF=\"calendar.php?do=getinfo&e=$ev[eventid]&day=$new_date&c=1\">$news</A>";

}
}


?>

"Fatal error: Call to a member function on a non-object in /home/socalbi/public_html/bikenights.php on line 6"

Whats that mean?

Dark_Wizard
07-24-2004, 06:14 PM
Use this:


<?php

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

$events = $DB_site->query("SELECT * FROM event ORDER BY dateline DESC LIMIT 1");

if ($DB_site->num_rows($events))
{
while ($ev = $DB_site->fetch_array($events))
{
$news = $ev['title'];

echo "<A HREF=\"calendar.php?do=getinfo&e=$ev[eventid]&day=$new_date&c=1\">$news</A>";

}
}


?>

Caster
07-24-2004, 06:25 PM
Thanks, but I'm still having a problem (its the php include problem) on my site, I put the script (bikenights.php) in my forums folder, (so I don't have to edit the script) and when I use <?php include('/forums/bikenight.php'); ?> it says:

"Warning: main(/forums/bikenights.php): failed to open stream: No such file or directory in /home/socalbi/public_html/index2.php on line 111"

Forgive me for being a noob, but php/mysql is just not my thing ><