从其他的具体情况不同,我发现这里的SO不能在PHP脚本运行mysql了shell_exec(.PHP)
我在主PHP脚本
include("sql.php"); //holds all the data to mysql (and variable $db to connect)
$output = shell_exec('/usr/local/bin/php folder/another_script.php')
下面的代码在another_script.php我有这样的:
include_once("../sql.php"); //notice difference to previous include in the other script
$query = "some query";
$db->query($query)
$ output在第一个脚本中是空白的。第二个脚本单独运行,而不是从另一个脚本调用。我错过了什么?
你为什么要这样做? –
@BartFriederichs出于某种原因,我敢肯定,否则我不会问...这并不重要。关键是我问为什么这不会这样工作。我不想通过不同的代码结构来运行它。 – Fane