Thanks for the reply ir4z0r, I've implemented you bits but I'm still getting the error. Here is my code for the page
<?
include('head1.php');
header('Content-type: application/octet-stream');
global $HTTP_USER_AGENT;
if(preg_match('/MSIE 5.5/', $HTTP_USER_AGENT) || preg_match('/MSIE 6.0/', $HTTP_USER_AGENT)) {
header('Content-Disposition: Filename="ce.csv"');
} else {
header('Content-Disposition: attachment; Filename="ce.csv"');
}
$start=$_GET['start'];
$end=$_GET['end'];
$sql=" SELECT ohead.order_id AS order_id,
ohead.auth_code AS auth_code,
users.name AS user_name,
product_type.short_name AS type_name,
product_type.product_type AS product_type,
oline.product_code AS product_code
FROM ohead, oline, users, new_products, product_type
WHERE ohead.order_id=oline.order_id
&& ohead.user_id=users.user_nr
&& oline.product_code = new_products.product_code
&& new_products.product_type=product_type.product_type
&& ohead.order_date>'".$start."'
&& ohead.order_date<'".$end."'
&& ohead.payment_type='EC'
&& (ohead.authorised='Y' || ohead.complete='Y')";
//echo($sql."<br>");
$result=db_read($sql);
$file_data="";
while($row=mysql_fetch_array($result)) {
$sql="SELECT title FROM ";
switch ($row['product_type']) {
case "1":
$sql.="cd_products";
break;
case "2":
$sql.="dvd_products";
break;
case "3":
$sql.="game_products";
break;
case "4":
$sql.="elec_products";
break;
case "9":
$sql.="alt_products";
break;
} //end switch
$sql.=" WHERE product_code='".$row['product_code']."'";
$result_t=db_read($sql);
$row_t=mysql_fetch_array($result_t);
$file_data.=$row['order_id'].",".$row['auth_code'].",".$row['user_name'].",".$row['type_name'].",".$row_t['title']."\n";
} //while
print($file_data);
?>
Any more ideas
Thanks
Rob