I'm calling a python script from my PHP code, I need to pass 7 variable: a few strings, a couple of array and a matrix.
I tried to use both Shell_Exec and exec(), but I get always the same problem:
matrixdata = sys.argv[7]
IndexError: list index out of range
The first thought was " I passed the wrong number of variable ", but checking they are 7. This is my python code:
listlabel = str(sys.argv[2])
listdata = (sys.argv[1])
typechart = str(sys.argv[3])
name = str(sys.argv[4])
typedata = str(sys.argv[5])
title = str(sys.argv[6])
matrixdata = sys.argv[7] //this is the matrix
This is my PHP Lines to call it
//json encoding for the array:
$total = json_encode(compact($listlabel));
$event = json_encode(compact($listdata));
$event = json_encode(compact($matrixdata));
exec("python ../home/path../create_chart.py $total $event $chart $name $typedata $title $matrixdata", $output);
//all the parameters exist and the path is correct
I'm passing 7 arguments, I'm getting 7 arguments. I don't understand where the problem is.
Before to added the last matrix, this line was working with 7 elements, instead of 7, I also tried with 8 elements and 9 instead of 7, but no luck.
Let me know if someone can help me, thank you.