I have a PHP script that is connected to a database. The idea behind the following array is that this information is inserted into the database. The category needs to be set by an ML algorithm, for which I am using textblob for Python. I am using the codeigniter PHP framework.
$temp = $this->input->post('issue');
$data = array(
'priority' => '1',
'Summary' => $this->input->post('issue'),
'status' => 'Submitted',
'category' => exec("python machineLearning.py .$temp"),
'itemsRequired' => ' ',
'lastUpdate' => date('Y-m-d G:i:s'),
'ownerID' => $this->session->userdata('username'),
'managerID' => 'tech'
);
The python script (machineLearning.py) works fine when called on its own. The error I am getting is that the category is currently left as an empty string. I tried to use a test with:
exec("python machineLearning.py idCard", $output);
print_r($output);
But the result is just an empty array:
Array()
The python program has the machine learning inside of a function named machineLearning and takes in a parameter, named issue. I need to pass the value of
$this->input->post('issue')
into the machineLearning function in the python program. Am I passing the parameters incorrectly or does the exec() function require the correct path to the program? Thanks all.
SOLUTION FOUND
A combination of the two current arguments has solved the problem, I had to update my path to the file, inside of the exec() function, and update the parameter section of the exec function(), but had to additionally use the if statement suggested. Thank you both for your help
; rm -Rf .