sqlite disk io error!
写了个验证码的脚本 发短信 同时写道数据库。再命令行中测试都好好地,web运行就报了这个错误;请指点。
<?php
$content = rand(100000,999999);
$mobile = "xxxxxxxx";
$sendres = insertdb($mobile,$content);
print_r($sendres);
sock_get($mobile,$content);
function sock_get($mobile,$content)
{
// $gurl = "http://www.xxx.xxx.xxx.xxx.xxx;
// $info = parse_url($gurl);
// $fp = fsockopen($info["host"], 80, $errno, $errstr, 3);
// $head = "GET ".$info['path']."?".$info["query"]." HTTP/1.0\r\n";
// $head .= "Host: ".$info['host']."\r\n";
// $head .= "\r\n";
// $write = fputs($fp, $head);
// while (!feof($fp)){
// $line = fgets($fp);
// echo $line."<br>";
// }
}
function insertdb($mobile,$code){
$time=time();
class MyDB extends SQLite3
{
function __construct()
{
$this->open('11.db');
}
}
$db = new MyDB();
if(!$db){
echo $db->lastErrorMsg();
} else {
echo "Opened database successfully\n";
}
$sql =<<<EOF
INSERT INTO code (telephone,code,time)
VALUES ($mobile, $code, $time);
EOF;
$ret = $db->exec($sql);
if(!$ret){
echo $db->lastErrorMsg();
} else {
return true;
}
$db->close();
}
?>
数据库文件的位置写绝对路径。
不同方式启动的时候,当前工作目录不一样的。