-1

このステートメントはエラーを返します

データベースから結果を取得できません

$res =$dbcon->exec("select *from tablename ");
$res->fetch();

エラーを出します。

4

2 に答える 2

2

クエリにはスペースが必要です。

$res = $dbcon->exec("select * from tablename");

内容によって$dbconは、代わりに query メソッドを使用する必要がある場合があります (alok.kumar の回答の一部)。

$res = $dbcon->query("select * from tablename");

参照: http://www.php.net/manual/en/pdo.query.php

于 2013-08-13T16:40:57.237 に答える
2

1 つのクエリのみを変更する

          $res =$dbcon->exec("select *from tablename "); 
               to
                  $res =$dbcon->query("select *from tablename ");
于 2013-08-13T16:41:01.610 に答える