homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

PHP/ODBC Query problem

 2:53 pm on Apr 14, 2010 (gmt 0)

Using a ODBC driver to connect to a database.

Connection works ok:

$db = odbc_connect( 'database','username','password');

View all tables in database works ok:

$result = odbc_tables($db);
$tables = array();
while (odbc_fetch_row($result))

View all columns in table works ok:

$result = odbc_columns($db, "database", "", "table_name", "%");
while (odbc_fetch_row($result)) {
echo odbc_result_all($result);

However, when I try to make a query of my own it complains about the table name.

$result = odbc_exec($db, "SELECT * FROM table_name");

Warning: odbc_exec() [function.odbc-exec]: SQL error: [IBM][CLI Driver][DB2/AIX64] SQL0204N "username.table_name" is an undefined name. SQLSTATE=42704 , SQL state S0002

Anyone encountered this problem before? My only theory is that it's looking for username.table_name instead of table_name...



 3:16 pm on Apr 14, 2010 (gmt 0)

just curious, you have a table in your database named "table_name"?


 3:30 pm on Apr 14, 2010 (gmt 0)

^No, just makes it easier to explain that way.

Figured out the problem though.

If a table was called AREA_BLUE when I did a show tables it was only listed as BLUE. Therefore, in my query I had to use AREA.BLUE as the table name. It was confusing because I don't control these tables.


 3:45 pm on Apr 14, 2010 (gmt 0)

glad you figured it out =) good luck with the rest of your project. =)

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved