Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8376249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:23:09+00:00 2026-06-09T15:23:09+00:00

I want to create a CSV file from the SQL query results. Till now

  • 0

I want to create a CSV file from the SQL query results. Till now i have been using the local storage to store the file.
But now i want to open a ftp connection and open the file and write my chnages.

My code is as follow:

$ftp_server = "subdomain.domain.com";
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
$login_result = ftp_login($conn_id, 'uN@m3', '$pWd00');

$filename = 'ftp://uN@m3:$pWd00@subdomain.domain.com.com:21/db_user_export_'.time().'.csv';       //Change this to FTP URL of the server where File is going to be placed

function populateCSVforRightNowDatabase(){

global $database, $filename, $queryInterval, $logger;
/*My Query*/

if($resultSet->load()) {

    // Create or Overwrite file
    $handle = fopen($filename, 'w+');

    // Write the spreadsheet column titles / labels
    fputcsv($handle, array( /*columns*/));

    foreach($resultSet as $result) {
        fputcsv($handle, array(/*Results*/));
    }
} else {
        $message = "Load Error: " . $resultSet->getLoadError();
        $logger->error($message);
}
// Finish writing the csv
fclose($handle);

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T15:23:10+00:00Added an answer on June 9, 2026 at 3:23 pm

    fopen supports multiple read/write modes. However, the mode you selected, w+, is read/write mode, which is not supported by FTP. Barring other errors, using w or a instead should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have C# Dictionary and I want create a .csv file from it. For
I want to create a CSV file from our Sage Abra Suite database using
I'm stuck. I basically want to create a LOCAL data file (csv file) from
I want to download a file from server to a local host. i have
I want to create a table from xml spreadsheet or csv file in MySQL.
I am trying to create a CSV file from a dynamically generated table.I have
I want to send a csv file from Android to Python AppEngine. I'm using
I want to create a barplot and my data is in a csv file
i want create a custom json data from the mssql 2008 results so that
i want create image animation , i have 50 images with png format now

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.