[英]php page run another script in background process not working
I've read this How can I run another PHP script using PHP? 我读过这个如何使用PHP运行另一个PHP脚本? and some other sources.
和其他一些来源。
so i have 2 files. 所以我有2个文件。 testexec.php and testfile.php, the purpose of the testfile.php is to insert some query into table.
testexec.php和testfile.php,testfile.php的目的是在表中插入一些查询。 the result running testexec.php is a success but no data inserted.
运行testexec.php的结果是成功但没有插入数据。 i try accessing testfile.php directly and the data is inserted.
我尝试直接访问testfile.php并插入数据。
in testexec.php: 在testexec.php中:
<?php
ignore_user_abort(true);
$pathFile = dirname(__FILE__) . "/textfile.php";
$cmd = "usr/bin/php " . $pathFile;
exec( $cmd , $output, $return);
if(!$return) {
echo "Fail";
} else {
echo "Success" . "<br/>";
}
?>
in testfile.php 在testfile.php中
<?php
include("database.php");
$myDB = new Database();
$dateTime = new DateTime();
$query = "INSERT INTO marking (description) VALUES ('Test Exec');";
$result = $myDB->insertMysqli($query);
if($result) {
echo "success";
} else {
echo "fail";
}
?>
Try to replace the lines 尝试更换线条
$cmd = "usr/bin/php " . $pathFile;
By 通过
$cmd = "/usr/bin/php " . $pathFile;
And 和
include("database.php");
By 通过
include(dirname(__FILE__) ."/database.php");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.