help with mysql statement

I HAD a script running on apache that gets data from a MySQL database running in the same machine. I now have moved the MySQL database to a different server and need help with the following code. I am running the code from my old apache server.

Before, it was:

        $file = "/path/file1.txt";
        # Dump the aliases,email to a file
        $command = "echo \"SELECT alias,email INTO OUTFILE '".$file."' FIELDS TERMINATED BY ':' FROM forwarding;\" | mysql -u root -ptest db1";
        print `$command`;

Now its:

        $file = "/path/file1.txt";
        # Dump the aliases,email to a file
        $command = "echo \"SELECT alias,email INTO OUTFILE '".$file."' FIELDS TERMINATED BY ':' FROM forwarding;\" | mysql -h newserver -u root -ptest db1";
        print `$command`;

However, the new code tries to write to the 'newserver' but I want to write to the old server. How can I change this code?
IUAATechAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
$command = "echo \"SELECT alias,email FIELDS TERMINATED BY ':' FROM forwarding;\" | mysql -h newserver -u root -ptest db1 > $file";
IUAATechAuthor Commented:
ozo,
I get
ERROR 1064 at line 1: You have an error in your SQL syntax.  Check the manual that corresponds to your MySQL server version for the right syntax to use near 'FIELDS TERMINATED BY ':' FROM forwarding' at line 1
IUAATechAuthor Commented:
I ended up writing to the 'newserver' and then I copied over the file using NET::FTP. Thanks for trying :-)
GranModCommented:
Closed, 250 points refunded.
GranMod
The Experts Exchange
Community Support Moderator of all Ages

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.