I am using Raspberry Pi, python and PHP. I can't get my count(output)
into my php (I am using apache2). I code my raspberry pi in terminal (command prompt). I have tried using exec()
and shell_exec()
, however there is no output.
This are the code I have tried
exec("python /home/pi/testing.py");
$file = popen("/home/pi/testing.py","r");
echo $file
pclose($file);
<?php
#command = escapeshellcmd('/home/pi/testing.py');
$output = shell_exec($command);
echo $output;
?>
<!DOCTYPE html>
<html>
<head>
<style>
table,th,td {
border:1px solid black;
}
</style>
</head>
<body>
<?php
echo "<br>";
echo date ('y-m-d H:i:s');
$conn = new mysqli("localhost","root","password","menagerie");
if($conn->connect_error)
{
die("connection failed:" . $conn->connect_error);
}
$sql = "SELECT * FROM people";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "<table><tr><th>Vistor</th><th>Entry</th></tr>";
while($row = $result->fetch_assoc()) {
echo "<tr><td>" . $row["vistor"]. " </td><td> " . $row["Date"]. "
</td></tr>";
}
echo"</table>";
}
$conn->close();
?>
""<br>
""<br>
</body>
</html>