odbc connection with ms access over LAN

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
korb
Forum Newbie
Posts: 5
Joined: Fri Jun 24, 2005 11:44 am
Location: London

odbc connection with ms access over LAN

Post by korb »

Hello

for last couple of hours I'm trying to access MsAccess db - which is on win xp pc - from GNU/Linux machine (they are in LAN). The code works on winXp machine, but I don't know what to do to access from another machine. The page with script just doesn't load.
(Linux machine is running PHP 4.3)
That's the code, it's from php documentation.

Code: Select all

<?php
$con = odbc_connect('ip/dns_name','msAccessDbUser','msAccessDbPass'); 

if ($con)
{
  echo "odbc connected<br>";
  $sql =  "select * from Menu";
  $exc = odbc_exec($con,$sql); 
}
else
  echo "odbc not connected<br>";
if($exc)
{
  echo "selection completed<br>";
  while($row = odbc_fetch_object($exc) )
       echo $row->Level."<br>";
}
else
  echo "selection failed<br>";
?>
please, help....

yours
Korb
d11wtq | Please use

Code: Select all

tags when posting PHP code[/color]
facets
Forum Contributor
Posts: 273
Joined: Wed Apr 13, 2005 1:53 am
Location: Detroit

Post by facets »

stab in the dark here..
is the M$Access DB listening for calls on local or IP address?
ie,(from cmd console netstat -n)
From the two examples below 1st is taking local requests the other is taking IP requests.
127.0.0.1:2826 127.0.0.1:2825 ESTABLISHED
192.168.0.12:1029 63.247.70.254:80 TIME_WAIT
korb
Forum Newbie
Posts: 5
Joined: Fri Jun 24, 2005 11:44 am
Location: London

Post by korb »

uuppsss
it's taking only local requests. I know that it's not windows board
but what should I do, do I need Samba or sth like that ???
I'm not familiar with microsoft products. Being honest for last 3 years I have been working only on Linux. One more time, PLease help.

yours
Korb

when I tried to execute script from the command line it says:

Warning: SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQLConnect in /srv/www/htdocs/catalog/korb/csv.php on line 3
User avatar
dethron
Forum Contributor
Posts: 370
Joined: Sat Apr 27, 2002 11:39 am
Location: Istanbul

Post by dethron »

i am not familiar with the topic, but again it sounds you need to install some data provider or something like that.

try to run your code on windows machine, i think it will not work since your windows can't found a provider to access database file.
korb
Forum Newbie
Posts: 5
Joined: Fri Jun 24, 2005 11:44 am
Location: London

Post by korb »

It works on Windows

maybe I'm using wrong livrary for php,
with php-odbc-6...:

linux:/srv/www/htdocs/catalog/korb # php -n csv.php

Fatal error: Call to undefined function: odbc_connect() in /srv/www/htdocs/catalog/korb/csv.php on line 3

linux:/srv/www/htdocs/catalog/korb # php csv.php

Warning: SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQLConnect in /srv/www/htdocs/catalog/korb/csv.php on line 3


with php-unixODBC which comes with this SUSE dist:

linux:/srv/www/htdocs/catalog/korb # php csv.php

php: symbol lookup error: /usr/lib/php/extensions/unixODBC.so: undefined symbol: SQLAllocEnv

linux:/srv/www/htdocs/catalog/korb # php -n csv.php

Fatal error: Call to undefined function: odbc_connect() in /srv/www/htdocs/catalog/korb/csv.php on line 3
Post Reply