dongmuyuan3046 2018-08-13 05:54
浏览 130

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

I created three files, one which processes the data a user fills in on a second file. Calendar2.php is supposed to display the events a user creates into the correct time slots and person but I keep getting an error message forenter image description here this code.

"Fatal error: Call to undefined method SQLite3::execute() in /net/laguna/h1/m/member300/public_html/calendar2.php on line 63"

I am not sure what I am doing wrong. Any suggestions?

#!/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>
  • 写回答

1条回答 默认 最新

  • dtz46697 2018-08-13 06:25
    关注

    You're supposed to call execute() on the statement handle, not the database.

    $result = $stmt->execute();
    

    Documentation

    评论

报告相同问题?

悬赏问题

  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 ubuntu系统下挂载磁盘上执行./提示权限不够
  • ¥15 Arcgis相交分析无法绘制一个或多个图形
  • ¥15 关于#r语言#的问题:差异分析前数据准备,报错Error in data[, sampleName1] : subscript out of bounds请问怎么解决呀以下是全部代码:
  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误
  • ¥30 3天&7天&&15天&销量如何统计同一行
  • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码