Forum Moderators: coopster
My knowledge is not enough to fix it, can anyone here help?
It comes up with the following error:
"error 1064: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1"
Code is as follows:
<?php
session_start();
include_once("db_functions.ins");
include_once("asset.php");
$total=0;
$dateFormat="%D %b %Y";
$now=getdate();
//header('Content-Type: application/x-msexcel');
//header('Content-Disposition: attachment; filename=\"Invoice.xls\"');
$sql="select * from asset where assetID=".$_REQUEST['clientID'];
$r=db_query($sql);
$select=$r[0];
echo "<html><body><table border=1>";
$sql="select t1.* from asset t1 where t1.deleted is null and t1.linkID=".$select['assetID'];
//echo $sql;
$classes=db_query($sql);
echo "<tr><td colspan=".(count($classes)*3)." align=right>company name<br>address 1, <BR>address 2, <BR>address 3, <BR>address 4, <BR>address 5</td></tr>\n";
echo "<tr><th colspan=".(count($classes)*3).">Register</th></tr>\n";
echo "<tr><td>Client Name</td><td colspan=4>".$select['name']."</td></tr>\n";
echo "<tr><td>Classes</td><td colspan=".(count($classes)*3).">".count($classes)."</td></tr>\n";
if(count($classes)) {
for($j=0;$j<count($classes);$j++) {
$sql="select t1.*, DATE_FORMAT(t2.date, '%D %b %Y %r') bDate, DATE_FORMAT(t2.startDate, '%D %b %Y %r') bStartDate, DATE_FORMAT(t2.endDate, '%D %b %Y %r') bEndDate, t2.qty, t2.clientID, t2.pending from asset t1 left join booking t2 on t1.assetID = t2.clientID where t2.deleted is null and t2.typeID=3 and t2.roomID=".$classes[$j]['assetID'];
//echo $sql."<BR>";
$assoc=db_query($sql);
$classes[$j]['classes']=$assoc;
if($max<count($assoc))$max=count($assoc);
}
for($i=-2;$i<$max;$i++) {
echo "<tr>";
for($j=0;$j<count($classes);$j++) {
if($i==-2)echo "<th colspan=3>".$classes[$j]['name']."</th>";
else if($i==-1)echo "<th>Name</th><th>Status</th><th>Date</th>";
else {
$class=$classes[$j]['classes'];
echo "<td>".$class[$i]['name']."</td><td>".$class[$i]['pending']."</td><td>".$class[$i]['bDate']."</td>";
}
}
echo "</tr>";
}
}
echo "</table></body></html>";
?>
A couple of your database queries need a slight alteration:
For example this:
$sql="select * from asset where assetID=".$_REQUEST['clientID'];
Needs to be this:
$sql="select * from asset where assetID='".$_REQUEST['clientID']."';
Note the single and double quotes in the query.
assetID='".$_REQUEST['clientID']."';
Your other queries need to be the same. Hope that helps.
dc