致命的なエラー:11行目の/home/content/69/9179269/html/test/json-events.phpにある非オブジェクトのメンバー関数fetchAll()を呼び出す
$result = $dbh->query($sql)->fetchAll(PDO::FETCH_ASSOC);
このエラーの原因は何ですか?
`$username = "user";
$password = "psword";
$dbh = new PDO("mysql:localhost;dbname=databasename", $username, $password);
$sql = "SELECT `id`, `title`, `time`, `start`, `end`, `url`, `backgroundColor`, `textColor`, `borderColor`, `description`
FROM calender WHERE length(column) > 0";`
foreach ($result as $row){
$return[]=array('id'=>$row['id'],
'title'=>$row['title'],
'start'=>$row['start'].' '.$row['time'],
'end'=>$row['end'],
'url'=>$row['url'],
'backgroundColor'=>$row['backgroundColor'],
'textColor'=>$row['textColor'],
'borderColor'=>$row['borderColor'],
'description'=>$row['description'],
"allDay" => false);
}
$dbh = null;
header('Content-type: application/json');
echo json_encode($return);