我下面有简单的PHP代码,在其中输入值并提交按钮即可运行php代码。表truncate和新值正在按需要存储,但我无法在其中执行python脚本。
<form action="" method="post">
Twittersearch: <input type="text" name="name"><br>
<input type="Submit">
</form>
<?php
$name = $_POST['name'];
$namesearch = $_POST['namesearch'];
# Database Access
$servername = 'localhost';
$username = 'a';
$password = 'a';
$dbname = 'a';
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "TRUNCATE TABLE `abc`";
#$sql = "INSERT INTO `abc`(`searchstring`, `handle`) VALUES ('".$name."','".$namesearch."')";
$sql = "UPDATE `abc` SET `searchstring` = '".$name."', `handle` = 'TEST' WHERE `searchstring` <> '12rm012m101101mkl'";
$result = $conn->query($sql);
echo "Put ".$customerName." into ".$clusterName." successfully!";
$command = escapeshellcmd('C:\Users\xyz\AppData\Local\Programs\Python\Python37-32\python.exe C:\Users\xyz\AppData\Local\Programs\Python\Python37-32\twitterhandle.py');
$output = shell_exec($command);
echo $output;
?>