I want to execute a php doc through another php doc using the exec() function. The code I have works on my local setup but for some reason it fails on my remote setup.
If I type the command directly in the command line php /home/user/domains/sitename/public_html/testing/doc1.php or php /home/user/domains/sitename/public_html/testing/doc2.php testing as any user, it executes fine and I see one new database entry. If I run doc1 directly from the browser it fails.
Folders are permission 755 and php docs are 644.
Anyone have any ideas?
Doc 1
exec('php /home/user/domains/sitename/public_html/testing/exec_test.php testing');
Doc 2 in above directory
include("/home/user/domains/sitename/public_html/connection_dir/connection.php");
$db = new PDOConnectionFactory();
$conn = $db->getConnection();
//prepare for utf8 characters
$sql = 'SET NAMES utf8';
$stmt = $conn->prepare($sql);
$result=$stmt->execute();
$sql = 'SET CHARACTER SET utf8';
$stmt = $conn->prepare($sql);
$result=$stmt->execute();
//**************************
$test=$argv[1];
$sql = 'INSERT INTO video
(field1, field2, field3, field4, field5, field6) VALUES(?,?,?,?,?,?)';
$stmt3 = $conn->prepare($sql);
$result=$stmt3->execute(array('','',$test,'','untitled','1'));
&$outputparameter ofexec()to see what you get back. At a guess, I'd say you need to provide the full path to thephpbinary, eg/usr/bin/php