Hello all,
First time poster and really would appreciate any help with this as I'm pulling my hair out.
I have a script which basically queries a MSSQL DB to pull names into a calendar to display a shift pattern.
I'm getting an "undefined variable" error on line 39 related to the $connected variable declared at the top of the script.
Any ideas why ?
Here is the top portion of my script.......
<?php
$connected = sqlsrv_connect('servername', array('UID'=>'username', 'PWD'=>'Password', 'Database'=>'inventory'));
class maxCalendar{
function showCalendar($year=0,$month=0){
$sql = "select NAMPrimarySA,NAMSecondarySA,EMEAPrimarySA,EMEASecondarySA from winteloncall where month1= " . $month . " and dayofmonth = ";
// Get today, reference day, first day and last day info
if (($year == 0) || ($month == 0)){
$referenceDay = getdate();
} else {
$referenceDay = getdate(mktime(0,0,0,$month,1,$year));
}
$firstDay = getdate(mktime(0,0,0,$referenceDay['mon'],1,$referenceDay['year']));
$lastDay = getdate(mktime(0,0,0,$referenceDay['mon']+1,0,$referenceDay['year']));
$today = getdate();
// Create a table with the necessary header informations
echo '<table class="month">';
echo '<tr><th colspan="7">'.$referenceDay['month']." - ".$referenceDay['year'] . "</th></tr>";
echo ' <tr class="days"><td>Monday</td><td>Tuesday</td><td>Wednesday</td><td>Thursday</td><td>Friday</td><td>Saturday</td><td>Sunday</td></tr>';
// Display the first calendar row with correct positioning
echo '<tr>';
if ($firstDay['wday'] == 0) $firstDay['wday'] = 7;
for($i=1;$i<$firstDay['wday'];$i++){
echo '<td> </td>';
}
$actday = 0;
for($i=$firstDay['wday'];$i<=7;$i++){
$actday++;
$sql1 = $sql. $actday;
[COLOR="red"]$line = sqlsrv_query($connected, $sql1);[/COLOR] $line1 = sqlsrv_fetch_array($line);
if (($actday == $today['mday']) && ($today['mon'] == $month)) {
$class = ' class="actday"';
} else {
$class = '';