I try to run another PHP script through exec(), which works without the line $conn = new mysqli($db['host'],$db['uid'],$db['pwd'], $db['db']);
(creates log file) but doesn't work with it (no log file).
In the browser db.php works fine with the connection line.
exec.php
<?php
$processid = exec('php db.php 2>&1 &', $output);
echo $processid;
print_r($output);
?>
=> Fatal error: Class 'mysqli' not found in db.php
db.php
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
ob_start();
$db = array(
'host' => 'localhost',
'db' => 'db',
'uid' => 'user',
'pwd' => 'pwd'
);
$conn = new mysqli($db['host'],$db['uid'],$db['pwd'], $db['db']); //Tested with and without
// // Check connection
// if ($conn->connect_error) {
// die("Connection failed: " . $conn->connect_error);
// }
// $con = $conn;
echo "Test";
$htmlStr = ob_get_contents();
ob_end_clean();
file_put_contents('testdblog.txt', $htmlStr);
?>