Output file to Excel sheet Problem

Discussion in 'PHP' started by Om ji Kesharwani, Mar 4, 2010.

  1. #1
    <?
    $sql="SELECT member_id,income_type,total_amount
    FROM pay_count
    INTO OUTFILE 'order.xls'
    FIELDS TERMINATED BY '\t'
    ENCLOSED BY '|'
    LINES TERMINATED BY '\n'";
    
    
    $omu=mysql_query($sql)or die('Error, Please contact to technical department');
    
    echo "created";
    
    ?>
    Code (markup):
    I am using obove code to output file into Excel. It works fine when i test it locally and a file order.xls is created into mysql/data/dbname directory

    But whats the error while using online and where the new file will be created.
     
    Om ji Kesharwani, Mar 4, 2010 IP
  2. sunlcik

    sunlcik Peon

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hmm...

    You should go to the directory where the database is."DATABASE_DIRECTORY",

    *nix: /var/lib/mysql/DATABASE_NAME
    windows:DATABASE_DIRECTORY

    Hope it can help you.By the way you also can change the SQL:

    yours:
    $sql="SELECT member_id,income_type,total_amount
    FROM pay_count
    INTO OUTFILE 'order.xls'
    FIELDS TERMINATED BY '\t'
    ENCLOSED BY '|'
    LINES TERMINATED BY '\n'";
    HTML:
    mine:
    $sql="SELECT member_id,income_type,total_amount
    FROM pay_count
    INTO OUTFILE '/tmp/order.xls(where do you want to save)'
    FIELDS TERMINATED BY '\t'
    ENCLOSED BY '|'
    LINES TERMINATED BY '\n'";
     
    sunlcik, Mar 4, 2010 IP
  3. Om ji Kesharwani

    Om ji Kesharwani Peon

    Messages:
    211
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks I used your code but the same error.
     
    Om ji Kesharwani, Mar 5, 2010 IP
  4. fibi

    fibi Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    It seems that "online" your data base does not have default directory. Try to set a valid path on your online server.
     
    fibi, Mar 5, 2010 IP
  5. sunlcik

    sunlcik Peon

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You should go to the directory where the database is."DATABASE_DIRECTORY"
     
    sunlcik, Mar 5, 2010 IP
  6. Om ji Kesharwani

    Om ji Kesharwani Peon

    Messages:
    211
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Please tell me where to find database files in case of online.
    i searched all the directory on my web server but didnt find.
    In case of locally i know it.
     
    Om ji Kesharwani, Mar 6, 2010 IP