My perl file and php file are in the same folder. I'm calling php script from perl in cmd
My database.pl script
#!/usr/bin/perl
while (2)
{
my $php = `sample.php`;
sleep (10);
}
My sample.php file
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "mydb";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "UPDATE users SET name1='Doe' WHERE id=1";
if ($conn->query($sql) === TRUE) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . $conn->error;
}
$conn->close();
?>
Now when i run database.pl
file, my sample.php
file is opening in an editor for every 10 second.. Now how should i make my php file to run, so that it should run UPDATE query.