I have a simple shell_exec()
script in my php script. On upload this line is run:
shell_exec("php process.php > /dev/null &");
It definitely runs the file happily in the background as intended, but it seems to have trouble connecting to mysql in process.php
process.php includes:
$db_host="localhost";
$db_name="databasename";
$dbusername="root";
$dbpassword="pass";
mysql_connect($db_host,$dbusername,$dbpassword);
mysql_select_db($db_name);
//then a mysql_query()
It seems that mysql_connect()
fails. If I copy and paste all of this into the first file in place of my shell_exec()
it works fine.
Is there something about 'localhost' as the mysql host when running shell_exec()
? I am testing in xampp on mac btw