Page 1 of 1

odbc connection with ms access over LAN

Posted: Fri Jun 24, 2005 11:50 am
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]

Posted: Sat Jun 25, 2005 12:36 am
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

Posted: Sat Jun 25, 2005 5:36 am
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

Posted: Sat Jun 25, 2005 8:56 am
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.

Posted: Sat Jun 25, 2005 8:59 am
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