SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2003
    Location
    Montgomery, TX
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Backing up mySQL with PHP

    I'm using the following script that I found in a previous thread to try to backup my mySQL db from PHP. When I run it, I get the error "Problem: 1". What is problem 1?

    PHP Code:
    <?php
    // Include your user and password $user $pass
    // outside the public folder
    require 'db.php';

    // Mysql Database Information:
    $database $db// name of the database.
    $username $user// username with access to database.
    $password $pass// password for username.

    // Database Backup Filename & Location
    $backupto '/public_html/diablos/backup'// absolute path to folder containing database - no trailing slash.
    $backupas $database '.sql' '.gz';

    // Perform backup
    $backupcommand "mysqldump -u$username -p$password $database | gzip >$backupto/$backupas";
    passthru("$backupcommand"$error);
    if(
    $error) {
    echo (
    "Problem: $error\n" ); exit;
    }
    ?>
    Thanks

  2. #2
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm no shell nerd but shouldn't there be space between -u and $username, the same goes for -p and $password
    else they will all get mixed up...
    - website

  3. #3
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If I may ask too, is the backup file created? does it work (without the error 1 ofcourse) ?
    - website

  4. #4
    SitePoint Enthusiast
    Join Date
    Apr 2003
    Location
    Montgomery, TX
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Putting a space between -u $username and -p $password has no effect. The file does not get created.


Bookmarks

Posting Permissions

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