Welcome to Stafford Forum. Please or sign-up and start posting!
i tend to lay code out like that as well.. just makes it easy to read and troubleshoot.. though, as you say, if a weird ansi character gets in there somehow, which just looks like a space or line break, it can fubar the whole statement!shoes said:can i ask why you stacked a short statement onto so many lines or was that just for readability here?
<?php
require_once('db_connect.php');
$doc = new DOMDocument();
$xsl = new XSLTProcessor();
$doc->load('2.xslt');
$xsl->importStyleSheet($doc);
$filename = date('omd') . "LampPercentReport.xml";
echo $filename;
$doc->load($filename);
$output = $xsl->transformToXML($doc);
file_put_contents('output.php', $output);
include('output.php');
if(mysql_errno() == 0) {
echo 'Database insert succesful';
} else {
echo mysql_errno();
}
?>
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" />
<xsl:template match="/">
<xsl:text><?php</xsl:text>
<xsl:variable name="Date"><xsl:value-of select="Average_Dim_Levels/Date"/></xsl:variable>
<xsl:for-each select="Average_Dim_Levels/Floor">
<xsl:variable name="Floor"><xsl:value-of select="Floor"/></xsl:variable>
<xsl:variable name="FloorID"><xsl:value-of select="FloorID"/></xsl:variable>
<xsl:for-each select="Channel">
$sql = 'INSERT INTO channel(datestamp, floor, floorid, output, location, rating, onmins, avdimlevel)
VALUES ("<xsl:value-of select="$Date"/>", "<xsl:value-of select="$Floor"/>", <xsl:value-of select="$FloorID"/>, "<xsl:value-of select="Output"/>", "<xsl:value-of select="Location"/>", <xsl:value-of select="Rating"/>, <xsl:value-of select="OnMins"/>, <xsl:value-of select="AvgDimLevel"/>)'; <xsl:text>
</xsl:text>
$result = mysql_query($sql); <xsl:text>
</xsl:text>
mysql_error();<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:for-each>
<xsl:text>?></xsl:text>
</xsl:template>
</xsl:stylesheet>