Koozali.org: home of the SME Server
Obsolete Releases => SME 7.x Contribs => Topic started by: schlagg on November 12, 2007, 03:06:33 PM
-
Hello,
here's my question :
actually, i've a part of my website on a windows server (Apache2 and PHP 5.2.3)
On this website, i've a PHP script which allows a connection with an MS Access database :
...
$connectionString = sprintf("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=%s", $chemin_complet);
$cnx = odbc_connect($connectionString, "", "");
$ressource_ta = odbc_exec($cnx, "SELECT C.date, valeur FROM access_base C ORDER BY date DESC");
...
This works very fine.
But now, i want to move this part of my website to my sme-server : 7.2 with PHP 4.3.9 and Apache2
i copy the Acess DB to an SME ibay and change its dir in the php script, but the script won't work, and i've no error to report :sad:
what i've missed?
Thanks for your help.
-
Hello,
here's my question :
actually, i've a part of my website on a windows server (Apache2 and PHP 5.2.3)
On this website, i've a PHP script which allows a connection with an MS Access database :
...
$connectionString = sprintf("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=%s", $chemin_complet);
$cnx = odbc_connect($connectionString, "", "");
$ressource_ta = odbc_exec($cnx, "SELECT C.date, valeur FROM access_base C ORDER BY date DESC");
...
This works very fine.
But now, i want to move this part of my website to my sme-server : 7.2 with PHP 4.3.9 and Apache2
i copy the Acess DB to an SME ibay and change its dir in the php script, but the script won't work, and i've no error to report :sad:
what i've missed?
Thanks for your help.
Have a look in the /var/log/messages file and the /var/log/httpd/error_log files at the time you were trying (e.g. the error occurred). I once posted this in the wiki to (temporarily) enable the display of error messages: http://wiki.contribs.org/PHP#Display_Error_Messages
-
Have a look in the /var/log/messages file and the /var/log/httpd/error_log files at the time you were trying (e.g. the error occurred).
No error concerning this script in those files.
My MS Access Database is located in :
Windows server :
C:\Program Files\Test\AccessDB
so the script is :
$chemin_complet = 'C:\\Program Files\\Test\\AccessDB';
$connectionString = sprintf("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=%s", $chemin_complet);
SME Server
/home/e-smith/files/ibays/doctest/files/AccessDB
i change the script to :
$chemin_complet = 'home//e-smith//files//ibays//doctest//files//AccessDB'
$connectionString = sprintf("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=%s", $chemin_complet);
i've made test with simple "/", with "//", "\", or "\\"
but nothing work
is there something else to do or connect to a MS database is not possibe with a linux server??
Thanks for your answers ..
-
i change the script to :
$chemin_complet = 'home//e-smith//files//ibays//doctest//files//AccessDB'
$connectionString = sprintf("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=%s", $chemin_complet);
i've made test with simple "/", with "//", "\", or "\\"
but nothing work
is there something else to do or connect to a MS database is not possibe with a linux server??
Thanks for your answers ..
Linux does not have native support for MS Access like windows does as you seem to build an ODBC connection in your application. BTW Why don't you have trailing slashes in the path to the access database, like //home/e-smith//...?
Is there an error returned in the php script when you connect? You are only building the connection string here and not actually connecting to the database.
-
Linux does not have native support for MS Access like windows does as you seem to build an ODBC connection in your application. BTW Why don't you have trailing slashes in the path to the access database, like //home/e-smith//...?
i made this already, but same thing
Is there an error returned in the php script when you connect? You are only building the connection string here and not actually connecting to the database.
No error
and after the connection string, i connect to the db with :
$cnx = odbc_connect($connectionString, "", "");
$reponse = odbc_exec($cnx, "SELECT C.date, Value FROM test C ORDER BY date DESC");
But if there is no support for Access DB, i think i'm good for an Access / MySQL convertion ....
Thanks again.
-
No error
and after the connection string, i connect to the db with :
$cnx = odbc_connect($connectionString, "", "");
$reponse = odbc_exec($cnx, "SELECT C.date, Value FROM test C ORDER BY date DESC");
Are you sure there is no error? I do not see any error code checking in your code, perhaps you should read up on PHP and ODBC (http://www.php.net/manual/en/ref.uodbc.php).
I am wondering what would be the result if you change your two lines of code to this:
//Set display_errors parameter to On
ini_set('display_errors', 'On');
//Connect and check for error
$cnx = odbc_connect($connectionString, "", "");
if (odbc_error($cnx) != "") die (odbc_error($cnx) . ": " . odbc_errormsg($cnx));
//Query and check for error
$reponse = odbc_exec($cnx, "SELECT C.date, Value FROM test C ORDER BY date DESC");
if (odbc_error($cnx) != "") die (odbc_error($cnx) . ": " . odbc_errormsg($cnx));
-
//Set display_errors parameter to On
ini_set('display_errors', 'On');
//Connect and check for error
$cnx = odbc_connect($connectionString, "", "");
if (odbc_error($cnx) != "") die (odbc_error($cnx) . ": " . odbc_errormsg($cnx));
//Query and check for error
$reponse = odbc_exec($cnx, "SELECT C.date, Value FROM test C ORDER BY date DESC");
if (odbc_error($cnx) != "") die (odbc_error($cnx) . ": " . odbc_errormsg($cnx));
Ok, i've got some times to tests the code, and you're right there is an error :
Fatal error: Call to undefined function: odbc_connect() in /home/e-smith/files/ibays/Primary/html/tests/test.php on line 117
so the odbc functions are not defined.
is there a way to define them?
Thanks ...
-
Unix ODBC is explained here:
http://www.unixodbc.org/
I've used these open source ODBC setups to get linux machines to talk to external MS SQL databases. Seems to me you should be able to get it working with local files too.
-E
-
Hello
finally, seems to work, but can we put a dynamic name to the database??
i explain : my application create a new MS Access Database per month
exemple :
in octobre i've ../DB/2007/10/database1.mdb, database2.mdb
in novembre, i've ../DB/2007/11/database1.mdb, database2.mdb
etc ...
in windows server, i can access to them in PHP with variables in the Database Dir ...
but, in Linux server, it seems that we have to put the databe Dir in a "static" file : /etc/odbc.ini
[vo20]
Description = Microsoft Access Database of vo20
Driver = MDBToolsODBC
Database = ../ibay/DB/2007/10/database1.mdb
Servername = localhost
UserName =
Password =
port = 5432
so, how can i change dinamycally the Database dir??
Thanks a lot.
-
I'm not positive on an answer here. I would suggest a cron job that runs a script at the beginning of each month to recreate the odbc.ini file with the correct path. Your script could use the $date command and then parse it out to the correct string to write the file out.
I doubt that you can actually make the odbc.ini dynamic itself but I haven't read the entire set of docs on their site.
-E