LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-05-2006, 10:37 AM   #1
BillyGalbreath
Member
 
Registered: Nov 2005
Location: Houston Texas
Distribution: Debian Sid
Posts: 379

Rep: Reputation: 31
Apache2, PHP4, MySQL 4.1, & ODBC


I run Debian Sarge 3.1r0a (no graphical invironment) on my server. It currently runs Apache2, PHP4, and MySQL 4.1.

I am going to be doing a project for my job (inventory control), however, they use IIS on a windows box and use ODBC for PHP4 to talk to MySQL4.1.

How can I get ODBC installed on my system to work the way my job's intranet server is?

PHP4 makes the ODBC calls rather than MySQL calls in the code. The ODBC (from what I understand of it) then passes these calls to the MySQL server.

I'm a little new to ODBC here and I read on google that it can be installed/used on Linux, but I can't seem to understand exactly HOW to install and use it.

Can someone give me a pretty good walk through on how to install and use ODBC with MySQL 4.1 on Linux running Apache2 for an ODBC beginner?

Thanks!
 
Old 01-05-2006, 12:33 PM   #2
cafletch
LQ Newbie
 
Registered: Sep 2004
Distribution: Gentoo 2005.1
Posts: 9

Rep: Reputation: 0
ODBC is an protocol to talk to databases, defined many years ago for windows machines.

I am confused with what you are trying to accomplish. I think it is : Your debian server runs the database and the company IIS server is going to access the database, MySQL. Not sure how PHP4 comes into play.

In order for the windows box (and IIS) to connect to your server/database, you will need to install the MySQL ODBC drivers on the Windows box. You can download them from http://dev.mysql.com/downloads/
 
Old 01-05-2006, 01:39 PM   #3
devbro
Member
 
Registered: Jul 2005
Posts: 74

Rep: Reputation: 15
ODBC was originally made to mask the differences between different databases (MS SQL,Oracle, DB2, MySql,...).
If you can not install ODBC for your php then do use a masker function for all your db calls.

a masker takes the parameters and does the data retrieve. if for any reason you need to modify the connection type then you only modify your masker function not your original code, changes can happen at the script installation stage.
 
Old 01-05-2006, 02:39 PM   #4
cafletch
LQ Newbie
 
Registered: Sep 2004
Distribution: Gentoo 2005.1
Posts: 9

Rep: Reputation: 0
FYI, The 'masker function' for all database calls is known as the Data Access Object pattern.
 
Old 01-05-2006, 03:33 PM   #5
BillyGalbreath
Member
 
Registered: Nov 2005
Location: Houston Texas
Distribution: Debian Sid
Posts: 379

Original Poster
Rep: Reputation: 31
Elaboration:

I have a server at home running Apache2, PHP4, MySQL 4.1 -- At my job the server is Windows 2000 with IIS, PHP4, MySQL 4.1, and ODBC.

I am building this inventory project at home on my own time (off the clock). I cannot program the inventory at home with ODBC just yet because I do not have ODBC installed on my home server.

If I program the project without ODBC then when I bring it to work to place the code on the windows server, its not going to work because PHP will not directly communicate with the MySQL server. It MUST go through the ODBC.

I am trying to mimic my job's server with ODBC so that when I bring the code from home up here to work, it will work without having to change any code at all.

If I cannot get ODBC on my linux server, then my only alternative is to install Windows 2000 on a new home server.

I do not have access to my job's servers, so I cannot just program directly to that server for testing. All development/testing will be done on my home server, then once completed will be brough tto my job's server.

My question is:

How do I setup ODBC on my home (linux) server so I can program my project in PHP4 using ODBC instead of direct MySQL calls at home? Once my project is coded using ODBC calls at home on linux, will the code work perfectly once on the windows server with no changes at all to the code?
 
Old 01-05-2006, 03:39 PM   #6
cafletch
LQ Newbie
 
Registered: Sep 2004
Distribution: Gentoo 2005.1
Posts: 9

Rep: Reputation: 0
Building something for the eployer off the clock. They must pay you really well and treat you nice.

You will have to go to the dev.mysql.com/downloads page and get the odbc drivers.. You may have to rebuild PHP to include the odbc extensions. Running a php script with php_info() should tell you if odbc was configured / loadable module support is built in...

debian may even have a packages (libmyodbc, myodbc)... another link http://www.mysql.com/products/connector/odbc/

-C
 
Old 01-05-2006, 03:50 PM   #7
BillyGalbreath
Member
 
Registered: Nov 2005
Location: Houston Texas
Distribution: Debian Sid
Posts: 379

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by cafletch
Building something for the eployer off the clock. They must pay you really well and treat you nice.
Nope. Pay sucks. Treatment, just as bad. But when I am at home I like to program stuff. I do not have a college degree or any other type or training. Everything is self taught, so I cant get a job doing what I like to do. So for now, I just program whatever I can whenever I can. I find it to be more fun that actual work. And this inventory project will actually save me (and other employees) a lot of time at work. It is also building my portfolio for that one day someone does happen to offer me a job in this field.

Thanks for the info too. I'll check out the debian repos to see if anything is there that will work, if not I'll download the drivers and rebuild php.
 
Old 01-07-2006, 01:25 AM   #8
BillyGalbreath
Member
 
Registered: Nov 2005
Location: Houston Texas
Distribution: Debian Sid
Posts: 379

Original Poster
Rep: Reputation: 31
well. i am back to where i started, only this time i have a better understanding of what odbc is exactly... Still no ODBC support in PHP4 though.

Ok, here's what I did. I uninstalled all php and apache packages from my debian server. I figured it would be best to do it all at once to get a brand new system up and going.

Ok. So then I start installing things. I got a fresh new 'virgin' copy of apache2 up with the default config files. I installed the php4 packages, including the php4-odbc package. I installed unixODBC. I downloaded MyODBC from dev.mysql.com/downloads like mentioned before.

Ok, so I have all my tools on the machine ( i think ). I start to google up answers and read doc files on my machine about how to configure unixODBC. I then read up and installed the MyODBC from mysql.com... I then did the tests i saw from multiple sites doing:

# isql -v MySQL-test

This failed probably at least a hundred times until i finally got it to work correctly and display a workable error. I then played with it more and figured out i had to feed it a user/pass in the CLI.

# isql -v MySQL-test root password

Brilliant. It displayed the data correctly. This means ODBC is now setup and works on my server. Sweet. Time to move on to php4 and apache2...

Ok, so I get this sumple script from the net and place it on my server (i edited some of the stuff and built the test table and placed data in it for this test purpose):

Code:
<?
// make your connection below
$Connection = odbc_connect("MySQL-test","root","password");
$Result = odbc_exec($Connection, "select * from test");
$NewID = odbc_result($Result, 1);
odbc_free_result($Result);
// make here all what you want with the NewID
odbc_close($Connection);
?>
Well... Thats when I realized my php4 is not recognizing ODBC commands...

Code:
Fatal error: Call to undefined function: odbc_connect() in /var/www/test.php on line 3
Ok, so i try checking google and php.net for how to enable this odbc support that i thought i installed when i installed php4-odbc from apt-get.

But thats where i think my problems are cooming from... I am installing from apt-get without giving any arguments at all. I do not like to compile my own stuff because i like what apt-get has to offer. Thats the whole reason why i use Debian, is for apt-get.

Ok, so i figured installing all this stuff with no arguments i think the default settings for all the packages are working together correctly or something.

Does anyone know what I can/should do now?

Detailed responses will probably be the only things i will understand seeing how i am new to odbc, and i am not good with compiling programs.

Thanks again!

Last edited by BillyGalbreath; 01-07-2006 at 01:26 AM.
 
Old 01-07-2006, 10:56 AM   #9
LLS
Member
 
Registered: Sep 2003
Location: North America
Distribution: FC6 FC7 F8
Posts: 75

Rep: Reputation: 15
Did you look at the ODBC section of /etc/php4/php.ini to make sure it is enabled? Also have you queryed the database from a terminal to make sure all is good there whith passwords users etc.
 
Old 01-07-2006, 07:57 PM   #10
BillyGalbreath
Member
 
Registered: Nov 2005
Location: Houston Texas
Distribution: Debian Sid
Posts: 379

Original Poster
Rep: Reputation: 31
*DELETED*

Ok it's fixed.

Turned out all that I needed was a new line in php.ini

extension=odbc.so

All works 100% now.

Thanks everyone!

Last edited by BillyGalbreath; 01-08-2006 at 10:59 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems upgrading MySQL on Ubuntu, with Apache2/PHP4 peruvianllama Linux - Software 0 08-16-2005 09:27 AM
Mandrake & Apache2/php4.2.3 how to enable GD extensions sablecurls Mandriva 1 07-09-2004 02:35 PM
Apache2 & prefork MPM, PHP4 XTJ7 Linux - Software 6 04-29-2004 02:43 PM
apache2 prefork + php4 + mysql rymonree Linux - Software 1 09-06-2003 02:03 PM
Apache2 & php4 CyberDrake Linux - Newbie 2 11-25-2002 11:32 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration