You are here: Re: mysql dump creates empty file « PHP SQL « IT news, forums, messages
Re: mysql dump creates empty file

Posted by J.O. Aho on 09/10/06 13:10

vesakilp@gmail.com wrote:
> I've got this problem: I'm trying to backup a table from my database to
> a .sql file. I'm running mysqldump command from php file, and the
> result file is empty. Where's the problem?
>
> Code:
> <?php
> include "settings.inc";
> include "db.php";
>
> global $dbase;
> global $duser;
> global $dpass;
>
> DBConnect();
>
> $backup = "mysqldump -h localhost -u $duser -p $dpass $dbase table_name
>> backup/table_name.sql";
> shell_exec($backup);
>
> DBClose();
> ?>
>
In theory this should work, but change your shell_exec($backup); to


$error_message=shell_exec($backup);
echo "Command used: ".$backup."<br>\nOutput from command:
".$error_message."<br>\n";

in your script, and then you see how your command line looks like and what the
command does output. By the way, as you are using the mysqldump command, you
don't need to connect to the database in the php script.

At least in the mysql command you don't have spaces between -u and the
password, the same for -p too and most likely for the -h too.

$backup = "mysqldump -hlocalhost -u$duser -p$dpass $dbase table_name >
backup/table_name.sql";


//Aho

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация