SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2000
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How's it going?

    I'm trying to use the following function to return a string with a dumped database in it.

    I get an error with this function when executing the shell command ('system' function call):

    'Warning: Unable to fork [mysqldump -u -p database_name > database_backup.sql] '

    ...and I was careful to make sure I put in my real database name.

    Also, I'm running locally (i.e. on windows) without a user name and password which is why these are set to "".

    Does anyone know what I'm doing wrong please?

    function mysql_dump_data($database_name = "my_database_name")

    {

    $user_name = "";
    $password = "";

    $sql_dump = "mysqldump -u$user_name -p$password $database_name > database_backup.sql";

    $sql_dump_result = system($sql_dump);

    echo "<br>\n sql_dump_result is " . $sql_dump_result;

    return $sql_dump;
    }

    Many thanks if you can assist,

    Regards,

    Jason

  2. #2
    SitePoint Guru prequel's Avatar
    Join Date
    Nov 1999
    Location
    Brisbane, Australia
    Posts
    682
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    not sure but don't you have to specify localhost ?
    mysqldump -u user localhost -p database_name > database_backup.sql

  3. #3
    SitePoint Zealot
    Join Date
    Jun 2000
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah, thanks, I've tried it with that also, but still can't get it to work...????????????????????

  4. #4
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One weird thing, I'm also testing,
    system("uptime"); gives result
    system("ls"); gives nothing

    Also, you might want to try backticks ( `command` )
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy


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
  •