0

i am calling python file to be executed from php this is my script:

  $sql = "INSERT INTO info (num_pause, duration, tot_time, time_arr,sess_id)
  VALUES ('$num_pause', '$tot_time','$duration','$time_arr','$sess')";

  if ($conn->query($sql) === TRUE) {

  // echo "New record created successfully";
   mysqli_close($conn);
  $result = exec("python db_Conn.py 
  C:/xampp/htdocs/Ai_Edutech_trial_project/eclipse_workspace/Project");
  echo $result; 
  $result_array = json_decode($result);
  foreach ($result_array as $row) {
    echo $row."<BR>";
  }
} else {
 echo "Error: " . $sql . "<br>" . $conn->error;
}   

the $sql is working fine but ..there is an error at $result line:

  Parse error: syntax error, unexpected 'echo' (T_ECHO) in 
C:\xampp\htdocs\Ai_Edutech_trial_project\Php_file\vid1\my_parse_file_one.php 
 on line 44

its showing error in

  echo $result

even if everything is fine... can someone suggest if there is any error in path

androfour
  • 17
  • 4
  • this aint duplicate , plzz give the connection resolutions – androfour Apr 14 '18 at 12:55
  • Have you read this https://stackoverflow.com/questions/19735250/running-a-python-script-from-php ? Also, if you are running a query using data sourced externally, you would be wise to implement prepared statements with placeholders for security reasons. `=== TRUE` can be removed. I would probably implode `$row` with `
    ` glue instead of looping. Lastly, I recommend tabbing your code properly and writing your executable script on one line.
    – mickmackusa Apr 15 '18 at 00:13

0 Answers0