Problems with PHP system() function
Posted: 19. May 2008 17:26
Hi Guys,
When trying to back up a mysql database using
system("mysqldump --opt -h$dbhost -u$dbuser -p$dbpass $dbname > $filename", $return);
It fails $return=255 and the apache error log says 'mysqldump' is not recognized as an internal or external command, operable program or batch file.
Using
system("C:\xampp\mysql\bin>mysqldump.exe --opt -h$dbhost -u$dbuser -p$dbpass $dbname > $filename", $return);
'works', well $return=0 but it fails to create the file. There is no error in the log.
I get similar problems with mysql and mysqlimport and I assume the rest of the commands. Are the mysql commands installed in XAMPP and if so, why do I need to give the exact address including.exe, if not how do I install them or which configuration file do I add them to? My xampp installation is located in C:\xampp and DocumentRoot "C:/home" not "C:/xampp/htdocs" as is standard if that is the source of my problems? I've set it up like that to replicate the server the website will be run on normally.
Many thanks!
When trying to back up a mysql database using
system("mysqldump --opt -h$dbhost -u$dbuser -p$dbpass $dbname > $filename", $return);
It fails $return=255 and the apache error log says 'mysqldump' is not recognized as an internal or external command, operable program or batch file.
Using
system("C:\xampp\mysql\bin>mysqldump.exe --opt -h$dbhost -u$dbuser -p$dbpass $dbname > $filename", $return);
'works', well $return=0 but it fails to create the file. There is no error in the log.
I get similar problems with mysql and mysqlimport and I assume the rest of the commands. Are the mysql commands installed in XAMPP and if so, why do I need to give the exact address including.exe, if not how do I install them or which configuration file do I add them to? My xampp installation is located in C:\xampp and DocumentRoot "C:/home" not "C:/xampp/htdocs" as is standard if that is the source of my problems? I've set it up like that to replicate the server the website will be run on normally.
Many thanks!