my calendar script works perfectly fine until I include it into my template. html within events.php is formatted fine but the connection to the database is not processed resulting in the errors you see below. Why is this happening, connection being lost/not processed?
<?php include ROOT . '/files/cal/events.php';?>
Errors:
Warning: mysql_connect() [function.mysql-connect]: Access denied for user ‘nobody’@’localhost’ (using password: NO) in /home/social/public_html/files/cal/smoothcalendar.php on line 19
Warning: mysql_select_db() expects parameter 2 to be resource, boolean given in /home/social/public_html/files/cal/smoothcalendar.php on line 21
Warning: mysql_query() expects parameter 2 to be resource, boolean given in /home/social/public_html/files/cal/smoothcalendar.php on line 195
Could not run query:
Warning: mysql_close() expects parameter 1 to be resource, boolean given in /home/social/public_html/files/cal/smoothcalendar.php on line 38
smoothcalendar.php
<?php
$server = "localhost";
$username = "****";
$password = "****";
$dbname = "***_socialdb";
class SmoothCalendar {
private $options = null,
$get,
$post;
private $connection;
function __construct($options)
{
$this->connection = mysql_connect($GLOBALS["server" ],
$GLOBALS["username"],
$GLOBALS["password"]);
mysql_select_db($GLOBALS["dbname"],$this->connection);
You probably have your
includeinside a function or something else, i.e., not in the global context. That’s why your variables can’t be reached using the $GLOBALS array… they’re not global.This should work: