Einzelnen Beitrag anzeigen
Alt 17.11.2009, 11:06  
da.eXecutoR
Erfahrener Benutzer
 
Registriert seit: 08.08.2009
Beiträge: 195
PHP-Kenntnisse:
Fortgeschritten
da.eXecutoR befindet sich auf einem aufstrebenden Ast
Standard

Hallo. Vielen Dank für eure Antworten!

Also ich hab eine Javascript Datei welche wie folgt aussieht:

HTML-Code:
var req;

function navigate(month,year,evt) {
	setFade(0);
	var url = "../../module/kalender/super_calendar.php?month="+month+"&year="+year+"&event="+evt;
	if(window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
	req.open("GET", url, true);
	req.onreadystatechange = callback;
	req.send(null);
}

function callback() {	
	if(req.readyState == 4) {
		var response = req.responseXML;	
		var resp = response.getElementsByTagName("response");
		getObject("list_events").innerHTML = resp[0].getElementsByTagName("termine")[0].childNodes[0].nodeValue;
		getObject("calendar").innerHTML = resp[0].getElementsByTagName("content")[0].childNodes[0].nodeValue;
		fade(70);
	}
}
Der Fehler den ich erhalte in der PHP Anwendung direkt, aufgerufen durch das Javascript File sieht wie folgt aus:

Details zum Fehler auf der Webseite

Benutzer-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2)
Zeitstempel: Tue, 17 Nov 2009 10:00:05 UTC

HTML-Code:
Meldung: '0' ist Null oder kein Objekt
Zeile: 20
Zeichen: 3
Code: 0
URI: http://server1/module/kalender/super_calendar.js
Zeile Zwanzig wäre dann folglich diese hier:

HTML-Code:
getObject("list_events").innerHTML = resp[0].getElementsByTagName("termine")[0].childNodes[0].nodeValue;
Und dies sagt mir als JS/Ajax Laien einfach mal dass ich keine XML Ausgabe zurück erhalte. Was ich wiederum anfangs auf eine nicht funktionierende Datenbankverbindung via include gehalten habe. Aber wenn ich den Pfad bewusst falsch schreibe kommt er auch mit Notice.... failed to include...

Das heists der Pfad stimmt. Die DB Informationen auch sonst würde die ganze Anwendung nicht funktionieren.

Wieso also kriege ich bei der externen DB Verbindung einen solchen Fehler und wenn die DB Informationen in der Datei selbst mit drin stehen nicht?

Das ist für mich einfach nicht nachvollziehbar.

Das mit dem error_reporting war eine sehr gute Idee, aber leider nicht das Problem.

Hier wäre mal noch die ganze durch AJAX aufgerufene super_calendar.php PHP Datei:

PHP-Code:
<?PHP 
header
("Expires: Mon, 26 Jul 1997 05:00:00 GMT" ); 
header("Last-Modified: " gmdate"D, d M Y H:i:s" ) . "GMT" ); 
header("Cache-Control: no-cache, must-revalidate" ); 
header("Pragma: no-cache" );
header("Content-Type: text/xml; charset=utf-8");

include(
'../../include/config.inc.php');

$xml '<?xml version="1.0" ?><response><content><![CDATA[';

if(
$_GET['event'] != '') {
    
$fields explode("-",$_GET['event']);
    
$result mysql_query("SELECT *,DATE_FORMAT(`date`,'%b %e, %Y at %l:%i%p') as thedate,DATE_FORMAT(`date`,'%c') as themonth,DATE_FORMAT(`date`,'%Y') as theyear FROM `modul_kalender_events` WHERE YEAR(`date`) = ".$fields[0]." AND MONTH(`date`) = ".$fields[1]." AND DAYOFMONTH(`date`) = ".$fields[2]." ORDER BY `num` ASC");
    
    
$i 0;
    while(
$row mysql_fetch_array($result)) {
        
$xml .= "<div id='event'";
        if(
$i < (mysql_num_rows($result)-1)) $xml .= " style='border-bottom:none'";
        
$xml .= "><div class='heading'><div class='title'>".$row['heading']."</div><div class='posted'>".$row['thedate']."</div>";
        if(
$i == 0$xml .= "<div class='back'><a href='javascript:navigate(".$row['themonth'].",".$row['theyear'].",\"\")'>Return to calendar</a></div>";
        
$xml .= "</div><div class='line'>".$row['body']."</div><br /></div><br />";
        
$i++;
    }
    
} else {
    
$month $_GET['month'];
    
$year $_GET['year'];
        
    if(
$month == '' && $year == '') { 
        
$time time();
        
$month date('n',$time);
        
$year date('Y',$time);
    }
    
    
$date getdate(mktime(0,0,0,$month,1,$year));
    
$today getdate();
    
$hours $today['hours'];
    
$mins $today['minutes'];
    
$secs $today['seconds'];
    
    if(
strlen($hours)<2$hours="0".$hours;
    if(
strlen($mins)<2$mins="0".$mins;
    if(
strlen($secs)<2$secs="0".$secs;
    
    
$days=date("t",mktime(0,0,0,$month,1,$year));
    
$start $date['wday']+1;
    
$name $date['month'];
    
$year2 $date['year'];
    
$offset $days $start 1;
     
    if(
$month==12) { 
        
$next=1
        
$nexty=$year 1
    } else { 
        
$next=$month 1
        
$nexty=$year
    }
    
    if(
$month==1) { 
        
$prev=12
        
$prevy=$year 1
    } else { 
        
$prev=$month 1
        
$prevy=$year
    }
    
    if(
$offset <= 28$weeks=28
    elseif(
$offset 35$weeks 42
    else 
$weeks 35
    
    
$xml .= "<table class='cal' cellpadding='0' cellspacing='1'>
            <tr>
                <td colspan='7' class='calhead'>
                    <table>
                    <tr>
                        <td>
                            <a href='javascript:navigate($prev,$prevy,\"\")' style='border:none'><img src='../../module/kalender/images/calLeft.gif' alt='prev' /></a> <a href='javascript:navigate(\"\",\"\",\"\")' style='border:none'><img src='../../module/kalender/images/calCenter.gif' alt='current' /></a> <a href='javascript:navigate($next,$nexty,\"\")' style='border:none'><img src='../../module/kalender/images/calRight.gif' alt='next' /></a> <a href='javascript:void(0)' onClick='showJump(this)' style='border:none'><img src='../../module/kalender/images/calDown.gif' alt='jump' /></a> 
                        </td>
                        <td align='right'>
                            $name $year2
                        </td>
                    </tr>
                    </table>
                </td>
            </tr>
            <tr class='dayhead'>
                <td>Son</td>
                <td>Mon</td>
                <td>Die</td>
                <td>Mit</td>
                <td>Don</td>
                <td>Fre</td>
                <td>Sam</td>
            </tr>"
;
    
    
$col=1;
    
$cur=1;
    
$next=0;
    
    for(
$i=1;$i<=$weeks;$i++) { 
        if(
$next==3$next=0;
        if(
$col==1$xml.="\n<tr class='dayrow'>"
          
        
$xml.="\t<td valign='top' onMouseOver=\"this.className='dayover'\" onMouseOut=\"this.className='dayout'\">";
    
        if(
$i <= ($days+($start-1)) && $i >= $start) {
            
$xml.="<div class='day'><b";
    
            if((
$cur==$today[mday]) && ($name==$today[month]) && ($year2==$today[year])) $xml.=" style='color:#C00'";
    
            
$xml.=">$cur</b></div>";
            
            
$result mysql_query("SELECT DATE_FORMAT(`date`,'%Y-%m-%e') FROM `modul_kalender_events` WHERE MONTHNAME(`date`)='$name' AND DAYOFMONTH(`date`)=$cur AND YEAR(`date`)=$year2");
            if(
mysql_num_rows($result) > 0) {
                
$row mysql_fetch_row($result);
                
$xml.="<div class='calevent'>Event</div>";            
            }
            
            
$xml.="\n\t</td>\n";
    
            
$cur++; 
            
$col++; 
            
        } else { 
            
$xml.="&nbsp;\n\t</td>\n"
            
$col++; 
        }  
            
        if(
$col==8) { 
            
$xml.="\n</tr>\n"
            
$col=1
        }
    }
    
    
$xml.="</table>";
      
}
    
$xml .= "]]></content>";

$xml .= "<termine><![CDATA[";
$xml .= "Termine im $name 2009";
$xml .= "<ul>";
$result mysql_query("SELECT * FROM `modul_kalender_events` WHERE MONTHNAME(`date`)='$name' AND YEAR(`date`)=$year2");
while(
$row mysql_fetch_assoc($result)){
        
$noevents 0;
        
$xml.= "<li>".$row['heading']."</li>";
}
if(!isset(
$noevents)){
    
$xml .= "<li>Keine Termine in diesem Monat.</li>";
}
$xml .="</ul>]]></termine>";
$xml .= "</response>";
echo 
$xml;
?>
Vielen vielen Dank für eure Hilfe!!!
da.eXecutoR ist offline