Rocket Software Homepage
Forum Home Forum Home > AccuTerm Knowledge Base (read only) > Connectivity
  New Posts New Posts RSS Feed - PHP ODBC connecting
  FAQ FAQ  Forum Search   Register Register  Login Login

The AccuTerm forum has moved. Go to community.rocketsoftware.com to register for the new Rocket forum.

Forum LockedPHP ODBC connecting

 Post Reply Post Reply
Author
Message
Tachikoma805 View Drop Down
Newbie
Newbie


Joined: May 15 2009
Location: United States
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote Tachikoma805 Quote  Post ReplyReply Direct Link To This Post Topic: PHP ODBC connecting
    Posted: February 12 2010 at 7:07am
Hello,

Our DBA has made some table views available for ODBC, and using the DSN for D3/pick, I can connect to them in UPS Worldship just fine, for what I need.

In the past, I used a lightweight client to view this data, again using the same DSN, and it has worked out well, letting me browse the table data.

So, now I want to make some of this data available on a Intranet page, for notifications (ex: open orders). I have a simple PHP script that runs and connects using the DSN, and based on the error I get, it looks like it connects alright, but I am somehow missing the proper commands?

Here is what I get when I run this:

Warning: odbc_exec() [function.odbc-exec]: SQL error: [Raining Data][ODBC D3 Driver]Syntax error, SQL state 37000 in SQLExecDirect in C:\wamp\www\components\com_jumi\jumi.php(25) : eval()'d code on line 9

Warning: odbc_fetch_row(): supplied argument is not a valid ODBC result resource in C:\wamp\www\components\com_jumi\jumi.php(25) : eval()'d code on line 12
Hi, I'm running!

And here is my script:

<?PHP
$connect = odbc_connect("FORESITE_VIEW", "KEY", "");
$query = "SELECT ORDER_NO, SHIPTO_NAME FROM KEY.ORDERINFO";
$result = odbc_exec($connect, $query);
while(odbc_fetch_row($result)){ $ORDER_NO = odbc_result($result, 1);
$SHIPTO_NAME = odbc_result($result, 2);
print("$ORDER_NO $SHIPTO_NAME"); }
print "Hi, I'm running!";
odbc_close($connect); ?>

I know my server is ok, as the PHP prints "Hi, I'm running!", but as to the error... I am at a loss?

Any insight?

Thanks,

Tachi
First toil, then the grave
Back to Top
mlucas67 View Drop Down
Senior Member
Senior Member


Joined: February 12 2007
Location: United States
Status: Offline
Points: 103
Post Options Post Options   Thanks (0) Thanks(0)   Quote mlucas67 Quote  Post ReplyReply Direct Link To This Post Posted: April 08 2010 at 6:53am
I believe you have to have ; at the end of the sql statement (and the php code line).  See code...
 

<?PHP
$connect = odbc_connect("FORESITE_VIEW", "KEY", "");
$query = "SELECT ORDER_NO, SHIPTO_NAME FROM KEY.ORDERINFO;";
$result = odbc_exec($connect, $query);
while(odbc_fetch_row($result)){ $ORDER_NO = odbc_result($result, 1);
$SHIPTO_NAME = odbc_result($result, 2);
print("$ORDER_NO $SHIPTO_NAME"); }
print "Hi, I'm running!";
odbc_close($connect); ?>
Back to Top
Tachikoma805 View Drop Down
Newbie
Newbie


Joined: May 15 2009
Location: United States
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote Tachikoma805 Quote  Post ReplyReply Direct Link To This Post Posted: April 08 2010 at 7:04am
Hmm, I used your code, but I get the same error:
Warning: odbc_exec() [function.odbc-exec]: SQL error: [Raining Data][ODBC D3 Driver]Syntax error, SQL state 37000 in SQLExecDirect in C:\wamp\www\components\com_jumi\jumi.php(25) : eval()'d code on line 4

Warning: odbc_fetch_row(): supplied argument is not a valid ODBC result resource in C:\wamp\www\components\com_jumi\jumi.php(25) : eval()'d code on line 5
Hi, I'm running!
First toil, then the grave
Back to Top
Tachikoma805 View Drop Down
Newbie
Newbie


Joined: May 15 2009
Location: United States
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote Tachikoma805 Quote  Post ReplyReply Direct Link To This Post Posted: April 08 2010 at 7:05am
Confusing thing though... I am not connecting to a SQL table, its ODBC to a D3 table view...
First toil, then the grave
Back to Top
mlucas67 View Drop Down
Senior Member
Senior Member


Joined: February 12 2007
Location: United States
Status: Offline
Points: 103
Post Options Post Options   Thanks (0) Thanks(0)   Quote mlucas67 Quote  Post ReplyReply Direct Link To This Post Posted: April 08 2010 at 7:10am
Well, now, that's the funny part...D3 ODBC presents itself as SQL which is why you send a SQL query to it and not a D3 Access query.
 
You might try posting to comp.databases.pick on Google Groups.  This in not strictly an AccuTerm question but a D3 ODBC question.
 
Thanks,
 
Marshall
Back to Top
Tachikoma805 View Drop Down
Newbie
Newbie


Joined: May 15 2009
Location: United States
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote Tachikoma805 Quote  Post ReplyReply Direct Link To This Post Posted: April 08 2010 at 7:14am
Thanks Marshall, I'll head over to Google... If i find the solution though, I'll at least post a link to it here... this is driving me batty.

Again, thanks!
First toil, then the grave
Back to Top
mlucas67 View Drop Down
Senior Member
Senior Member


Joined: February 12 2007
Location: United States
Status: Offline
Points: 103
Post Options Post Options   Thanks (0) Thanks(0)   Quote mlucas67 Quote  Post ReplyReply Direct Link To This Post Posted: April 08 2010 at 7:16am

Been there, wish I could help more, thought I had with the ; since that has bit me before.

Good luck!
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.03
Copyright ©2001-2019 Web Wiz Ltd.