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 697937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:13:10+00:00 2026-05-14T03:13:10+00:00

Not sure if I can do it this way. I want to get current

  • 0

Not sure if I can do it this way. I want to get current snapshot of the database and send it via FTP Server, both of this functionality should be implemented in PHP scripts.

Here are the steps I am thinking on right now.

In my php scripts(basically am extending an PDO into my Dao class and then preparing the query),

 $qry = SELECT * FROM MyTablename;
 $stmt = $this->prepare($qry);
 $stmt = $this->execute();

Now I will store $stmt in csv file using fputcsv or I will execute the sql command from the script itself and than try to store the result in the $file(csv file) note here that I do not have any csv file with me at this point to basically I will have to create one and let’s say its $file, so then

$file = fputcsv($stmt); or $file = exec("Select * from MyTablename");

Will this put all records in the file ? If yes, then I will use FTP Functionality to transfer file to the FTP Folder.

I am not sure if this approach would work and also have concerns regarding the need of preparing the $qry

Any suggestions or different approach advised would be highly appreciated.

Thanks !!!

  • 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-05-14T03:13:11+00:00Added an answer on May 14, 2026 at 3:13 am

    try something like this:

    mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); 
    mysql_select_db($dbname); 
    $list = array(); 
    $q = mysql_query("SELECT * from table"); 
    
    while($row = mysql_fetch_assoc($q)){ 
        $list[] = $row; 
        } 
    $fp = fopen("file.csv", 'w+'); 
    foreach ($list as $line) { 
        fputcsv ($fp, implode(',', $line)); 
    } 
    

    then try:

    $conn_id = ftpconnect('host',21);
    $login_result = ftp_login($conn_id, 'user_name', 'user_pass');
    ftp_fput($conn_id, 'file.csv', $fp, FTP_ASCII);
    
    ftp_close($conn_id);
    fclose($fp);
    

    I write the code without testing it but should be something like that 😉

    good luck.

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

Sidebar

Related Questions

I can get the element like this $(#txtEmail) but I'm not sure how to
I'm not sure what this practice is actually called, so perhaps someone can edit
I'm not sure I'm doing this the right way, so I'm open to other
I know how to use Perl's Getopt::Long, but I'm not sure how I can
Not sure if the title is quite right for the question but I can't
I'm not sure if namespaces are required for valid/correct XML. Can I add arbitrary
Not sure if this is possible or if I'm expressing correctly what I'm looking
Not sure how to ask a followup on SO, but this is in reference
Not sure if this is intended behavior or a bug or a wrong function
Ok I'm working on getting better with python, so I'm not sure this is

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.