Subject Re: ibase_query question
Author ke4dm
--- In firebird-support@yahoogroups.com, Lester Caine <lester@...> wrote:
>
> ke4dm wrote:
> > In order to learn how to use PHP (5.2.4) with Firebird, I have created
> > a table "entries" with four fields "id,title,content,date" in a
> > database blognew.fdb. I have entered four rows of data into the table.
> > Using Lester's tutorial as a guide, I wrote the following PHP script:
> >
> > <?php
> > $dbh = ibase_connect('localhost:/opt/fbdata/blognew.fdb', 'webuser',
> > 'webuser');
> > if (!$dbh)
> > {
> > echo "Error while connecting: ".ibase_errmsg();
> > exit();
> > }
> > $sth = ibase_query($dbh, "select * from entries");
> > while ($row = ibase_fetch_object($sth)) {
> > echo "$row->CONTENT";
> > }
> > ibase_close ($dbh);
> > ?>
> >
> > The connection apparently works, but the query fails with an error
> > code -204 "Table unknown ENTRIES". Any ideas on what I am doing wrong?
>
> Check the 'case' ;)
> If you have created "entries" you will need the double quotes in the
query!
> But it makes more sense to create ENTRIES so that we do not have to
manage
> extra double quotes in PHP.
>
> You will find the PHP users on
http://groups.yahoo.com/group/firebird-php/
>
> --
> Lester Caine - G8HFL
> -----------------------------
> Contact - http://home.lsces.co.uk/lsces/wiki/?page=contact
> L.S.Caine Electronic Services - http://home.lsces.co.uk
> MEDW - http://home.lsces.co.uk/ModelEngineersDigitalWorkshop/
> Firebird - http://www.firebirdsql.org/index.php
>
Lester,
Thanks for the fast response. I actually managed to solve the problem
about 10 minutes ago. Here is the code that works for me, but in the
future, thanks to you, I will know to use uppercase table and field names:

$dbh = ibase_connect("localhost:/opt/fbdata/blognew.fdb", "webuser",
"webuser");
if (!$dbh)
{
echo "Error while connecting: ".ibase_errmsg();
exit();
}
echo "connected to database. .<BR><BR>";
$sth = ibase_query($dbh, 'select * from "entries"'); //Note use of
single/double quotes!
if(!$sth){
echo "error retrieving row data";
}
while ($row = ibase_fetch_object($sth)) {
echo "$row->id ..."; //Note case of field names
echo "$row->title ...";
echo "$row->content ...";
echo "$row->date <BR>";
}
ibase_close ($dbh);
?