このステートメントはエラーを返します
データベースから結果を取得できません
$res =$dbcon->exec("select *from tablename ");
$res->fetch();
エラーを出します。
クエリにはスペースが必要です。
$res = $dbcon->exec("select * from tablename");
内容によって$dbcon
は、代わりに query メソッドを使用する必要がある場合があります (alok.kumar の回答の一部)。
$res = $dbcon->query("select * from tablename");
1 つのクエリのみを変更する
$res =$dbcon->exec("select *from tablename ");
to
$res =$dbcon->query("select *from tablename ");