PHP Exec Cron Job返回意外的EOF

I'm attempting to run a php script during a cron job to dump my MySQL database to a folder for a backup.

$DBHost = 'localhost';
$DBName = 'mydatabase';
$DBUser = 'myuser';
$DBPassword = 'mypassword';

$PATH = "/home/mysite/Backups/";
$FILE_NAME = "backup-" . date( "Y-m-d_H:i:s" ) . ".sql.gz";
exec( '/usr/local/bin/mysqldump -u ' . $DBName . ' -p' . $DBPassword . ' ' . $DBName . ' | gzip --best > ' . $PATH . $FILE_NAME );

But I keep getting the error:

sh: -c: line 0: unexpected EOF while looking for matching `)'

sh: -c: line 1: syntax error: unexpected end of file

I have checked all the ) and can't find any non-matching. If I comment out the exec command then I do not get the error.

Any one see what I am doing wrong?

Why don't write whole code in sh?

#!/bin/bash 
dbname="database"
dbuser="user"
dbpass="password"

path="/home/backup"

now=$(date + "%Y-%m-%d")

/usr/bin/mysqldump -u $dbuser -p$dbpass $dbname | gzip > $path/backup_$now.sql.gz

save it as e.g. backup.sh,

and then use crontab -e to add new cron job (e.g. 2:15 daily)

15 2 * * * /home/backup/backup.sh