Jump to content

Help with building the file name for export doc


hane

Recommended Posts

Hi for some reason I just cant get my code to work. Please take a look and help me in the right direction.

 

Here is my header builder for my export doc, $vExcelFileName is my problem:

<?php require_once('includes/connect.php');

$adid=$_GET['adid'];

mysql_select_db($database_A, $A);
$query_ads = "SELECT * FROM ads JOIN company ON ads.companyid=company.companyid JOIN contact ON contact.companyid=ads.companyid WHERE adid=$adid";
$ads = mysql_query($query_ads, $A) or die(mysql_error());
$row_ads = mysql_fetch_assoc($ads);
$totalRows_ads = mysql_num_rows($ads);

$vExcelFileName=$row_ads['name'] . "ad-description-" .  $row_ads['month'] ."-10" .  ".doc";
header("Content-type: application/x-ms-download"); //#-- build header to download the excel file
header("Content-Disposition: attachment; filename=$vExcelFileName");
header('Cache-Control: public');
?>

 

I'm sure its something silly that I'm not seeing and just need someone else to point it out

Link to comment
Share on other sites

I have checked the code and it works, but when a name has spaces it falls apart how can I fix that

Here is the problem:

 

$vExcelFileName=$row_ads['name'] . "ad-description-" .  $row_ads['month'] ."-10" .  ".doc";

Link to comment
Share on other sites

remember i call the info from my mysql database so I select AIP Africa from drop down then I select export and it exports all the info to a .doc file with the name populated with my the script in question

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.