我試圖用php從我的SQL Server數據庫中獲取數據,以便填充e XML文檔。但我有這個錯誤:Call to a member function saveXML() on a non-object in C:\xampp\htdocs\db\1mod.php on line 67
任何人都可以幫助我嗎?我能做什麼?在非對象上調用成員函數saveXML()
這是我的PHP文件
<?php
$file = fopen("C:/xampp/htdocs/result.xml","w");
ini_set('display_errors',1);
error_reporting(E_ALL);
$server = "USER-PC\SQLEXPRESS";
$options = array("UID"=>"", "PWD"=>"", "Database"=>"RESTORANTET");
$conn = sqlsrv_connect($server, $options);
if(!$conn)
{
echo mysql_error();
}
$Query = "SELECT MAX(ID_Rest) AS MAXID FROM RESTORANTET";
$Result = sqlsrv_query($conn,$Query)
or die("Query to get blah failed with error111: ".mysql_error());
$Row = sqlsrv_fetch_array($Result,SQLSRV_FETCH_ASSOC);
$nbPhase = $Row['MAXID'];
print "<TrafficPhase>";
$i = 1;
$k = 1;
while ($i <= $nbPhase)
{
print "<Phase>\n";
$Query1 = "SELECT * FROM RESTORANTET WHERE ID_Rest = $i";
$Result1 = sqlsrv_query($conn,$Query1) or die("Query to get blah failed with error222: ".mysql_error());
$Row1 = sqlsrv_fetch_array($Result1);
print "<Option_id>" .$k. "</Option_id>\n";
print "<name>" .$Row1['Emri_Rest']. "</name>\n";
print "<Option_Concept_ID>" .$Row1['Lloji_i_ushqimit']. "</Option_Concept_ID>\n";
$i = $i + 1;
print "</Phase>\n";
}
print "</TrafficPhase>\n";
echo $file->saveXML();
fwrite($file, $xml->w);
fclose($file);
?>
提前感謝!