odbc error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

odbc error

Post 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);
 
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: odbc error

Post by s.dot »

How many rows does $result have? var_dump($result)
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Re: odbc error

Post by yacahuma »

I will try using var_dump when I get back to work. In terms of the tables, it returns like 30 tables.
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Re: odbc error

Post by yacahuma »

var_dump($results) displays

resource(3) of type (odbc result)

have no idea what resource(3) means
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Re: odbc error

Post 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?
Post Reply