Forum Moderators: coopster
The output is not what I expected, the fileds are misaligned and I think its because of some charaters in some of the items in the DB.
Is there an equivelent of a CDATA tag I can place in the csv file?
example.csv:
$linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host.");
mysql_select_db($database, $linkID) or die("Could not find database."); $q = "SELECT * FROM _PRODUCTS";
$qe = mysql_query($q);?>
[_PROD_NAME], [_PROD_IMAGE], [_PROD_LINK], [_PROD_DESCRIPTION], [_PROD_PRICE]
<? while($qr = mysql_fetch_array($qe))
{
?>
<?=$qr[_PROD_NAME]?>, <?=$qr[PROD_IMAGE]?>, <?=$qr[_PRODLINK]?>, <?=$qr[_PROD_DESCRIPTION]?>, <?=$qr[PROD_LINK]?>, <?=$qr[PROD_PRICE]?>
<?
}
?>
<?php
$q = "SELECT * FROM _PRODUCTS";
$qe = mysql_query($q);
$op = '[_PROD_NAME], [_PROD_IMAGE], [_PROD_LINK], [_PROD_DESCRIPTION], [_PROD_PRICE]'."\n";
while($qr = mysql_fetch_array($qe)) {
$op.= "{$qr[_PROD_NAME]}, {$qr[PROD_IMAGE]}, {$qr[_PROD_LINK]}, {$qr[_PROD_DESCRIPTION]}, {$qr[PROD_LINK]}, {$qr[PROD_PRICE]}\n";
}
echo $op;
$op.= "\"{$qr[_PROD_NAME]}\", \"{$qr[PROD_IMAGE]}\", \"{$qr[_PROD_LINK]}\", \"{$qr[_PROD_DESCRIPTION]}\", \"{$qr[PROD_LINK]}\", \"{$qr[PROD_PRICE]}\"\n";
I suspect that the problem in the formatting lies in your query.
// $q = "SELECT * FROM _PRODUCTS";
// try
$q = "SELECT [_PROD_NAME], [_PROD_IMAGE], [_PROD_LINK], [_PROD_DESCRIPTION], [_PROD_PRICE] FROM _PRODUCTS;";
As at the moment you are returning up to 8 fields with your select all statement.
See what just selecting the line you want does for the format.
<edit>
Unrelated to formatting issues -
When I typed the link into another computer to look at the output in windows and got the link address wrong your custom 404 page is not working.
As the response is the browser standard 404 with a warning 'Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request' so your 404 page is not working.
[edited by: PHP_Chimp at 4:15 pm (utc) on Jan. 10, 2008]