PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > alt.comp.lang.php > printing to excel
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
printing to excel

Réponse
 
LinkBack Outils de la discussion
Vieux 20/07/2007, 21h07   #1
gagal
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut printing to excel

I'm beginning to think I'm the queen of it worked before ... I used
this exact same page on another website I did. It worked
beautifully. On my site, it doesn't work. Instead of opening in
excel I get:

All of my data and ...

Warning: Cannot modify header information - headers already sent by
(output started at /home/smith/public_html/addressbook/ab_print.php:6)
in /home/smith/public_html/addressbook/ab_print.php on line 70

Warning: Cannot modify header information - headers already sent by
(output started at /home/smith/public_html/addressbook/ab_print.php:6)
in /home/smith/public_html/addressbook/ab_print.php on line 71

Warning: Cannot modify header information - headers already sent by
(output started at /home/smith/public_html/addressbook/ab_print.php:6)
in /home/smith/public_html/addressbook/ab_print.php on line 72

Warning: Cannot modify header information - headers already sent by
(output started at /home/smith/public_html/addressbook/ab_print.php:6)
in /home/smith/public_html/addressbook/ab_print.php on line 73

<HTML>
<HEAD>
</HEAD>
<BODY>

<?PHP include("../includes/connect.txt"); ?>
<?PHP
$sql = "SELECT * FROM $db_table4 ORDER BY category ASC, business ASC,
lastName ASC, firstName ASC";
$result = mysql_query ($sql, $connect) or die ('Query failed:
' .mysql_error());
echo "<TABLE CELLSPACING='2' CELLPADDING='2' BORDER='1'>";
echo "<TR>";
echo "<TD CLASS='title'>Category</TD>";
echo "<TD CLASS='title'>Business</TD>";
echo "<TD CLASS='title'>Name</TD>";
echo "<TD CLASS='title'>Address</TD>";
echo "<TD CLASS='title'>Address</TD>";
echo "<TD CLASS='title'>City</TD>";
echo "<TD CLASS='title'>State</TD>";
echo "<TD CLASS='title'>Zip</TD>";
echo "<TD CLASS='title'>Phone</TD>";
echo "<TD CLASS='title'>Cell</TD>";
echo "<TD CLASS='title'>Email</TD>";
echo "<TD CLASS='title'>Alternate Email</TD>";
echo "<TD CLASS='title'>AIM</TD>";
echo "<TD CLASS='title'>Notes</TD>";
echo "</TR>";
while ($row = mysql_fetch_array ($result))
{
echo "<TR>";
$business = $row['business'];
$lastName = $row['lastName'];
$firstName = $row['firstName'];
$category = $row['category'];
$telephone = $row['telephone'];
$area = substr($telephone,0,3);
$exchange = substr($telephone,3,3);
$rest = substr($telephone,6,4);
$cellphone = $row['cellphone'];
$areac = substr($cellphone,0,3);
$exchangec = substr($cellphone,3,3);
$restc = substr($cellphone,6,4);
$address1 = $row['address1'];
$address2 = $row['address2'];
$city = $row['city'];
$state = $row['state'];
$zip = $row['zipcode'];
$email1 = $row['email1'];
$$email2 = $row['$email2'];
$aimid = $row['aimid'];
$url = $row['url'];
$notes = $row['notes'];

echo "<TD>$category</TD>";
echo "<TD>$business</TD>";
echo "<TD>$lastName, $firstName</TD>";
echo "<TD>$address1</TD>";
echo "<TD>$address2</TD>";
echo "<TD>$city</TD>";
echo "<TD>$state</TD>";
echo "<TD>$zip</TD>";
echo "<TD>($area) $exchange-$rest</TD>";
echo "<TD>($areac) $exchangec-$restc</TD>";
echo "<TD>$email1</TD>";
echo "<TD>$email2</TD>";
echo "<TD>$aimid</TD>";
echo "<TD>$notes</TD>";
echo "</TR>";
}
echo "</TABLE>";
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=addressbook.xls");
header("Pragma: no-cache");
header("Expires: 0");
?>

</BODY>
</HTML>

  Réponse avec citation
Vieux 20/07/2007, 21h20   #2
Rik
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: printing to excel

On Fri, 20 Jul 2007 22:07:25 +0200, gagal <lynettesmith@gmail.com> wrote:

> I'm beginning to think I'm the queen of it worked before ... I used
> this exact same page on another website I did. It worked
> beautifully. On my site, it doesn't work. Instead of opening in
> excel I get:
> Warning: Cannot modify header information - headers already sent by
> (output started at /home/smith/public_html/addressbook/ab_print.php:6)
> in /home/smith/public_html/addressbook/ab_print.php on line 70
>
> <?PHP include("../includes/connect.txt"); ?>
> <?PHP
> $sql = "SELECT * FROM $db_table4 ORDER BY category ASC, business ASC,

..........
> echo "</TABLE>";
> header("Content-type: application/octet-stream");
> header("Content-Disposition: attachment; filename=addressbook.xls");
> header("Pragma: no-cache");
> header("Expires: 0");
> ?>


Well, on the other server there's obviously some outbut buffering on. Just
move all of your header() statements up and run them first before all
other output or content.
--
Rik Wasmus
  Réponse avec citation
Vieux 20/07/2007, 22h48   #3
ZeldorBlat
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: printing to excel

On Jul 20, 4:20 pm, Rik <luiheidsgoe...@hotmail.com> wrote:
> On Fri, 20 Jul 2007 22:07:25 +0200, gagal <lynettesm...@gmail.com> wrote:
> > I'm beginning to think I'm the queen of it worked before ... I used
> > this exact same page on another website I did. It worked
> > beautifully. On my site, it doesn't work. Instead of opening in
> > excel I get:
> > Warning: Cannot modify header information - headers already sent by
> > (output started at /home/smith/public_html/addressbook/ab_print.php:6)
> > in /home/smith/public_html/addressbook/ab_print.php on line 70

>
> > <?PHP include("../includes/connect.txt"); ?>
> > <?PHP
> > $sql = "SELECT * FROM $db_table4 ORDER BY category ASC, business ASC,

> .........
> > echo "</TABLE>";
> > header("Content-type: application/octet-stream");
> > header("Content-Disposition: attachment; filename=addressbook.xls");
> > header("Pragma: no-cache");
> > header("Expires: 0");
> > ?>

>
> Well, on the other server there's obviously some outbut buffering on. Just
> move all of your header() statements up and run them first before all
> other output or content.
> --
> Rik Wasmus


The problem could also be that display_errors is disabled on the
server.

In any event, Rik's solution should work.

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 13h12.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10297 seconds with 11 queries