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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:34:19+00:00 2026-06-08T13:34:19+00:00

So i am trying to make a backup class and this is what I

  • 0

So i am trying to make a backup class and this is what I have so far. Issue is the $tbl_data is empty. What am I doing wrong.

The connection to the database is successful.

Without the ‘echo $tbl_data’, the ‘$current_table – current table’ output is correct but if ‘echo $tbl_data’ is used, only the first table is shown ( trying to backup two tables to begin with ).

class mBackup{

private $_connection = ""; //db connection var
private $output = ""; //sql output
private $tbl_data = "";
private $tbl_row = "";
private $nfields = "";
private $create_table_query = "";
private $create_table_output = "";

public function __construct($dbhost,$dbname,$dbuser,$dbpassword){

    $this->_connection = new mysqli($dbhost,$dbuser,$dbpassword,$dbname);

    //possible connection error
    if($this->_connection->connect_errno){
        echo "Failed to connect to the DB";
    }
    else{
        echo "Connected<br />"; 
    }
}

public function backup_db(){

    //get the table names from the DB and store in an array
    $result = $this->_connection->query("SHOW TABLES");

    //get the TABLE names
    while($row = $result->fetch_row())
    {
        $table_names[] = $row[0];
    }

    //For each table
    foreach($table_names as $current_table)
    {
        echo $current_table." - current table<br />"; //debug

        $tbl_data = "";
        $tbl_row = "";
        $nfields = "";
        $create_table_query = "";
        $create_table_output = "";

        //SELECT Everything from the table in use       
        $query = $this->_connection->prepare("SELECT * FROM ?");
        $query->bind_param('s', $current_table);
        $query->execute();
        $query->bind_result($tbl_data);
        $query->fetch();

        echo $tbl_data."<br/>";

        }
}
  • 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-08T13:34:20+00:00Added an answer on June 8, 2026 at 1:34 pm

    Try something like:

    while ($query->fetch()) {
         echo $tbl_data;
    }
    

    and see if that gets you anything. From the little that I know, bind_result binds columns in the result set to variables. If your table has 5 columns, you should have bind_result($var1, $var2, $var3, $var4, $var5) but since your number of columns are going to change depending on the table, I don’t know if bind_result will give you what you need.

    Try closing the prepared statement after every loop

    $query->close();
    

    or resetting.

    $query->reset()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make a Postgres PHP backup script. I have downloaded one
I have make Some Differential Backup for a Database, which will take the Backup
I have this form: $form = array( '<form name=backup-form class=backup-form method=post action=#>', '<fieldset class=backup-fields>',
I'm trying to make a backup of a database, but for versioning purposes, I
I'm trying to make a bash script that's going to backup a db2 database
Trying to make this jQuery filter that uses .find case-insensitive. For example, when the
Trying to make a simple number clicker control for BlackBerry 6/7, like this: At
This is more of a conceptual question than anything. I have a base class
I am trying to make a backup for my data from my first table
I'm trying to make a batch file that makes a backup of the USB

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.