Page 1 of 1

odbc error

Posted: Wed Jan 16, 2008 1:29 pm
by yacahuma
I installed an odbc driver on my machine from a product called faircom. The drivers provides odbc access to a group of flat files c trees (or something like that). Using a product called winsql I can connect and do sql statements. So this proves the odbc is working.

PHP connects to the database and it works successfully calls odbc_tables.

BUT if I do a simple 'select * from tablename', I get

select * from LOANINFO
Warning: odbc_do() [function.odbc-do]: SQL error: [FairCom][FairCom ODBC Driver][FairCom File Library]No such table or object., SQL state S0002 in SQLExecDirect in C:\Users\oky\htdocs\mortgage\melapi.php on line 27

Warning: odbc_fetch_object(): supplied argument is not a valid ODBC result resource in C:\Users\oky\htdocs\mortgage\melapi.php on line 28


WHYYYYYYY?

It connects, thats why I get all the tables names. Why the select does not work???

Code: Select all

 
$db = odbc_connect('MELAPI','','');
 
$result = odbc_tables($db);
 
$tables = array();
while (odbc_fetch_row($result)){
     if(odbc_result($result,"TABLE_TYPE")=="TABLE")
       echo"<br>".odbc_result($result,"TABLE_NAME");
 
   }
   
$sql =  "select * from LOANINFO"; 
$qrs=odbc_do($db,$sql);
while ($obj = odbc_fetch_object($qrs))
  print_r($obj);
odbc_close($db);
 

Re: odbc error

Posted: Wed Jan 16, 2008 2:24 pm
by s.dot
How many rows does $result have? var_dump($result)

Re: odbc error

Posted: Wed Jan 16, 2008 6:26 pm
by yacahuma
I will try using var_dump when I get back to work. In terms of the tables, it returns like 30 tables.

Re: odbc error

Posted: Thu Jan 17, 2008 8:02 am
by yacahuma
var_dump($results) displays

resource(3) of type (odbc result)

have no idea what resource(3) means

Re: odbc error

Posted: Thu Jan 17, 2008 9:11 am
by yacahuma
The ghost strikes again.

I decided to run the script from the command line and it works. If I run the script from apache I get the error. I have the same problem connecting to mysql. From the cli works from apache does not. With oracle and oracle XE I have no problems.

I HATE VISTA.
It is definitively not a PHP error.

I will REALLY appreciate any ideas?