EdiSainer
EdiSainer

Reputation: 112

Error when creating events calendar in PHP

Please be advised, I am newbie in PHP. I don't know what i have to do with this calendar script. It's working good when i duplicate the line below manually:

$cal->addEvent('Event Title', 08, 9, 2013);

Then i create table for adding events dinamicly. Here my table SQL

CREATE TABLE IF NOT EXISTS `eventcalender` (
  `evt_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `evt_title` varchar(255) NOT NULL,
  `evt_year` varchar(255) NOT NULL,
  `evt_month` varchar(255) NOT NULL,
  `evt_date` date NOT NULL,
  PRIMARY KEY (`evt_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;

I'm using while() to display the events

   include('config.php');
    $get = mysql_query("SELECT * FROM `eventcalender` WHERE `evt_year`='".CURRENT_YEAR."' AND `evt_month`='".CURRENT_MONTH_N."'");
    while($s = mysql_fetch_array($get)){

    $titl = $s['evt_title'];
    $tah = substr($s['evt_date'],0,4);
    $har = substr($s['evt_date'],8,2);
    $bul = date('n');

    $cal->addEvent($titl, $har, $bul, $tah);
    }

But this not working. what's wrong?

Upvotes: 0

Views: 59

Answers (1)

Ariyan
Ariyan

Reputation: 15158

mysql_fetch_array returns indexed array but you're using returned array as an associative array.
So, Use:

while($s = mysql_fetch_assoc($get)){

Or

while($s = mysql_fetch_array($get,MYSQL_ASSOC)){

Upvotes: 1

Related Questions