phpを勉強しているのですが
Uncaught Error: Call to a member function execute() on boolean
このようなエラーの意味がわかりません。
ぐぐったのですが、既に実行されているのがどうとか...
詳しい方教えて下さい!!
lang
1<?php 2function insert_sql($table,$url,$content){ 3 4 try{ 5 /*dbに接続からSQLの実行まで*/ 6 $dbh = new PDO('sqlite:webapp.db',","); 7 $sql = "insert into "+ $table + "(url,contents) values(" + $url + "," + $content + ")"; 8 $sth = $dbh->prepare($sql); 9 $sth -> execute(); 10 $sth = $dbh->prepare("select * from " + $table); 11 $sth -> execute(); 12 13 while($row = $sth -> fetch()){ 14 echo $row[0].$row[1].$row[2]."<br>"; 15 } 16 }Catch(PODException $e){ 17 print "error[".$e->getMessage()."]<br/>"; 18 die(); 19 } 20} 21$url = "http://www.kyoto-su.ac.jp/"; 22$content = "test data"; 23 24insert_sql('list',$url,$content); 25 26?> 27
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。