Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 调用未定义的方法SQLite3::execute()_Php_Sqlite - Fatal编程技术网

Php 调用未定义的方法SQLite3::execute()

Php 调用未定义的方法SQLite3::execute(),php,sqlite,Php,Sqlite,我创建了三个文件,其中一个处理用户在第二个文件中填写的数据。Calendar2.php应该显示用户在正确的时间段和人员中创建的事件,但我一直收到此代码的错误消息 “致命错误:在第63行的/net/laguna/h1/m/member300/public_html/calendar2.php中调用未定义的方法SQLite3::execute()” 我不确定我做错了什么。有什么建议吗 #!/usr/local/bin/php <?php print '<?xml version="1.0

我创建了三个文件,其中一个处理用户在第二个文件中填写的数据。Calendar2.php应该显示用户在正确的时间段和人员中创建的事件,但我一直收到此代码的错误消息

“致命错误:在第63行的/net/laguna/h1/m/member300/public_html/calendar2.php中调用未定义的方法SQLite3::execute()”

我不确定我做错了什么。有什么建议吗

#!/usr/local/bin/php
<?php print '<?xml version="1.0" encoding="utf-8" ?> '; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Calendar</title>
<link rel="stylesheet" type="text/css" href="calender.css" />
</head>
<body>
 <div class="container">
<h1>Bruin Family Schedule for
<?php
$mode = "now";
if(isset($_GET['mode'])){
    $mode = $_GET['mode'];
}
date_default_timezone_set('America/Los_Angeles');
//unix timestamp
$unts= time();
// uses the data function to convert unts into the day of the week and so on 
$day_ofweek = date("l",$unts);
$month = date("M",$unts);
$day_ofmonth = date("d",$unts);
$year = date("Y",$unts);
$hour = date("h",$unts);
$minute = date("i", $unts);
$amorpm = date("a",$unts);
echo "$day_ofweek".", "."$month"." "."$day_ofmonth".", "."$year".", "."$hour".":"."$minute"."$amorpm ";
?>
</h1>

<table id="event_table">
   <tr>
       <th class='hr_td_blank'> &nbsp; </th>
       <th class='table_header'>Andy</th>
       <th class='table_header'>Abby</th>
       <th class='table_header'>Elsie</th>
    </tr>
<?php
// this functions gets the hours for the first column, variable t is passed into the function and is used to find the the hour and am/pm
function get_hour_string($t){
//initialize string hour_var 
 $hour_var = "";
   $amorpm = date("a",$t);
   $hour = date("h",$t);

   $hour_var = "$hour".":00"."$amorpm";
   return "$hour_var";
}
function get_events($person, $timestamp){
    $database = "dbyourusername.db";
    try
    {
         $db = new SQLite3($database);
    }
    catch (Exception $exception)
    {
        echo '<p>There was an error connecting to the database!</p>';
        if ($db)
        {
            echo $exception->getMessage();
        }
    }
    $stmt = $db->prepare("SELECT * FROM event_table WHERE person=:person AND time=:time");
    $stmt->bindValue(':person', $person);
    $stmt->bindValue(':time', $timestamp);
    $result = $db->execute($stmt);
    return $result->fetchArray();
}
$hours_to_show = 12;
$u_time = time();
if($mode = 'prev'){
    $u_time -= 3600 *12; 
}else if($mode = 'next'){
    $u_time += 3600*12;
}
//this for loop assigns even an odd row using mod
for($num_rows = 0; $num_rows <= $hours_to_show; $num_rows++)
{

    $andyEventStr = "";
    $abbyEventStr = "";
    $elsieEventStr = "";
    $andyEvent = get_events("Andy", $u_time);
    $abbyEvent = get_events("Abby", $u_time);
    $elsieEvent = get_events("Elsie", $u_time);
    if($andyEvent){
        $andyEventStr = $andyEvent['event_title'] . ": " . $andyEvent['event_message'];  
    }
    if($abbyEvent){
        $abbyEventStr = $abbyEvent['event_title'] . ": " . $abbyEvent['event_message'];  
    }
    if($elsieEvent){
        $elsieEventStr = $elsieEvent['event_title'] . ": " . $elsieEvent['event_message'];  
    }
    echo "<tr class=";
    if ($num_rows % 2 == 0)
       echo '"even_row">';
    else echo '"odd_row">';
    echo '<td class="hr_td">'. get_hour_string($u_time) . "</td>";
    echo "<td>" . $andyEventStr . "</td>";
    echo "<td>" . $abbyEventStr . "</td>";
    echo "<td>" . $elsieEventStr . "</td>";
    echo "</tr>";
    //increase $u_time by an hour each time you go through the loop
    $u_time += 3600;
}
?>
</table>
<form action="" method="GET">
    <input type="hidden" id="mode" value="prev">
    <button type="submit">Prev:</button>
</form>
<form action="" method="GET">
    <input type="hidden" id="mode" value="now">
    <button type="submit">Now: <?php time(); ?></button>
</form>
<form action="" method="GET">
    <input type="hidden" id="mode" value="next">
    <button type="submit">Next:</button>
</form>
</div>
    <p>
    <a href="http://validator.w3.org/check?uri=referer"><img
      src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Strict" height="31" width="88" /></a>
  </p>

</body>
</html>
#/usr/local/bin/php
历法
布鲁因病家庭时间表
安迪
艾比
埃尔西
上一页:
现在:
下一步:


您应该在语句句柄而不是数据库上调用
execute()

$result = $stmt->execute();