我想在后台启动一个 php 脚本。我正在做的是运行这段代码
<?php
while(true){
$commandString = 'start /b C:\xampp\php\php.exe "C:\xampp\htdocs\caliban\blobs.php"';
popen($commandString, 'r');
sleep(5);
}
?>
在网络浏览器中,但页面不会停止加载。如何执行此代码并停止网络浏览器进一步加载而不停止在后台完成的任务?
斑点.php
<?php
//pdo connect function
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
//third function
$firstname = rand(4,4);
$lastname = rand(4,4);
$city = rand(4,4);
$continent = rand(4,4);
$profile = rand(4,4);
$image = rand(4,4);
$sql = "INSERT INTO mymodels ".
"(firstname,lastname,city,continent,image,profile) ".
"VALUES ".
"('$firstname','$lastname','$city','$continent','$image','$profile')";
mysql_select_db('caliban');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Could not enter data: ' . mysql_error());
}
?>
Sql
create table mymodels(
id INT NOT NULL AUTO_INCREMENT,
firstname VARCHAR(100) NOT NULL,
lastname VARCHAR(40) NOT NULL,
city VARCHAR(40) NOT NULL,
continent VARCHAR(40) NOT NULL,
image BLOB,
profile VARCHAR(400) NOT NULL,
PRIMARY KEY ( id )
);