尝试将我的xml Feed添加到表中,遗漏了一些不起作用的内容。
警告:mysqli_query():无法获取mysqli / Users / John / Sites / XMLproject /更新第77行的Emperor.php
//Database variables
$servername = "localhost";
$username = "Something";
$password = "Very secret";
$dbname = "TestDB";
$temptable = "wlbvx_jb_xml_emperor";
//Open database
$conn = new mysqli($servername, $username, $password,$dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully to database: ","<strong>",$dbname,"</strong>","<br>" ;
?><br><?php
$url = "http://bookings.emperordivers.com/webScheduleSpecificXML_all.asp";
$feed = file_get_contents($url);
$xml = simplexml_load_string($feed);
//Row by row into variable, then into table
foreach ($xml->Schedule as $row) {
$ID = "Null";
$start = date("d-m-Y", strtotime($row->Start));
$duration = $row->Duration;
$boat = $row->Boat;
$itinerary = $row->Itinerary;
$spaces = $row->Spaces;
$rateseur = round(str_replace(',', '', $row->Rates->Rate[0]));
$rategbp = round(str_replace(',', '', $row->Rates->Rate[1]));
$rateusd = round(str_replace(',', '', $row->Rates->Rate[2]));
$sql = "INSERT INTO $temptable (id,xml_date, xml_duration, xml_boat, xml_itinerary, xml_spaces, xml_rate_eur, xml_rate_gbp, xml_rate_usd)VALUES ('{$ID}',{$start}', '{$duration}', '{$boat}', '{$itinerary}','{$spaces}', '{$rateseur}', '{$rategbp}', '{$rateusd}')";
echo "SQL Query to execute:",$sql,"<br>";
mysqli_query($conn, $sql);
}
什么可能导致问题?