Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2015
    Posts
    2

    Unanswered: how to download query data from mySQL

    Hi, I have a non-profit website that I've developed with PHP. I'm trying to make the logged in users can output letters in Word with selected data from a query in MySQL. I've tried to use PHPWord, the letters outputted with no data in the letters. Also I tried used PHP COM, but Hostforlife won't let me restart the server because it is shared.
    Lastly I wrote a SELECT query with INTO OUTFILE '$file' to create a CSV which the users could download and use to merge into Word, but because the database user does not have FILE access, it produces this error:

    Error: Access denied for user 'blabla'@'localhost' (using password: YES)

    I think Hostforlife will not allow FILE privileges on a shared server. So, how can I get around this. Somehow I want to be able to at least write the query and download the data. Javascript? jQuery? or Something else? Any of you can help me?

    Thanks in advance

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    You can create a CSV (and other similar files) in PHP without the need to write to disk.
    You do this by overriding the default content headers.

    For CSV you'd do something like:
    PHP Code:
    header('Content-Type: text/csv; charset=utf-8');
    header('Content-Disposition: attachment; filename=data.csv');

    // In memory file, no write to disk needed... just be careful with large amounts of data!
    $f fopen('php://memory''w'); 
    // Or...
    $f fopen('php://output''w'); 
    Been a long while since I did something like this with PDF files, so apologies if this is not perfect!
    Speaking of which, this is the library I used for PDF generation which might work for your requirements: http://www.fpdf.org/
    George
    Home | Blog

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    P.S. moving to the PHP topipc
    George
    Home | Blog

  4. #4
    Join Date
    Feb 2016
    Posts
    5

    Arrow

    You must have MySQL client libraries installed on your computer. We recommend using the most current version of the v5.0 MySQL clients.

    Connect to the MySQL server using the command:

    mysql --user=genome --host=genome-mysql.cse.ucsc.edu -A

    The -A flag is optional but is recommended for speed.

    Once connected to the database, you may use a wide range of MySQL commands to query the database.
    Conditions of Use

    Avoid excessive or heavy queries that may impact the server performance. Inappropriate query use will result in a restriction of access. If you plan to execute a query that you think may be excessive, contact UCSC first to avoid the possibility of having your access blocked. Bot access and excessive program-driven use are not permitted. Attachments by local mirror sites are prohibited.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •