PHP + ODBC

PHP + ODBC

am 15.12.2009 00:33:38 von Philip Thompson

Hello all.

My head hurts from hitting it on my desk all day, so I thought I'd turn =
to a fresher set of eyes. The issue I'm having is getting PHP to connect =
ODBC. I can get it to work using isql from the command line. Can you =
verify my settings....:

/etc/odbc.ini:

[MySQL]
Description =3D MySQL 3.51 ODBC driver
Driver =3D MySQL
Host =3D s-irv-web02
Server =3D s-irv-web02
UID =3D user
Password =3D pass
Database =3D clients
Port =3D 3306

/etc/odbcinst.ini:

[MySQL]
Description =3D ODBC 3.51 for MySQL
Driver =3D /usr/lib/libmyodbc3.so
Setup =3D /usr/lib/libodbcmyS.so
FileUsage =3D 1
UsageCount =3D 2

Again, isql allows me to connect with the same settings as above: isql =
MySQL user pass

I've tried several settings in PHP to attempt to connect to it. All have =
been fruitless:

$user =3D 'user';
$pass =3D 'pass';
$dsn =3D "Driver=3D{MySQL};Server=3Ds-irv-web02;Host=3Ds-irv-web02;";
$dsn =3D "Driver=3D{MySQL 3.51 ODBC =
driver};Server=3Ds-irv-web02;Host=3Ds-irv-web02;";
$dsn =3D =
"Driver=3D{MySQL};Server=3Ds-irv-web02;Host=3Ds-irv-web02;Us er=3D$user;Pas=
sword=3D$pass";
odbc_connect ($dsn, $user, $pass);
?>

I've tried the above DSNs and many other versions of it ad nauseum. The =
specific error I'm getting is... "[unixODBC][Driver Manager]Data source =
name not found, and no default driver specified." I really have searched =
high and low for a solution, but to no avail. Any thoughts?

Thanks in advance,
~Philip=

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP + ODBC

am 15.12.2009 03:47:12 von James Mclean

On Tue, Dec 15, 2009 at 10:03 AM, Philip Thompson
wrote:
> My head hurts from hitting it on my desk all day, so I thought I'd turn t=
o a fresher set of eyes. The issue I'm having is getting PHP to connect ODB=
C. I can get it to work using isql from the command line. Can you verify my=
settings....:
>
[snipped]
>
> I've tried the above DSNs and many other versions of it ad nauseum. The s=
pecific error I'm getting is... "[unixODBC][Driver Manager]Data source name=
not found, and no default driver specified." I really have searched high a=
nd low for a solution, but to no avail. Any thoughts?

Why not just use the built in MySQL libraries or PDO?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP + ODBC

am 15.12.2009 16:13:47 von Philip Thompson

On Dec 14, 2009, at 8:47 PM, James McLean wrote:

> On Tue, Dec 15, 2009 at 10:03 AM, Philip Thompson
> wrote:
>> My head hurts from hitting it on my desk all day, so I thought I'd =
turn to a fresher set of eyes. The issue I'm having is getting PHP to =
connect ODBC. I can get it to work using isql from the command line. Can =
you verify my settings....:
>>=20
> [snipped]
>>=20
>> I've tried the above DSNs and many other versions of it ad nauseum. =
The specific error I'm getting is... "[unixODBC][Driver Manager]Data =
source name not found, and no default driver specified." I really have =
searched high and low for a solution, but to no avail. Any thoughts?
>=20
> Why not just use the built in MySQL libraries or PDO?

Oh, that would be "my" preference. However, the database that I really =
need to connect to is an MSSQL one and the allowed connection type is =
ODBC. I was just testing first with a MySQL connection to get it working =
(I don't have the MSSQL credentials yet). Turned out I was VERY close =
with my solution, which a coworker figured out this morning. The [ODBC =
Data Sources] entry for MySQL needed to specified correctly in =
/etc/odbc.ini.

[ODBC Data Sources]
MySQL =3D MySQL

[MySQL]
Description...
Driver...

I could have sworn I tried that, but who knows....

Thank you!
~Philip=

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP + ODBC

am 15.12.2009 16:50:34 von Richard Quadling

2009/12/15 Philip Thompson :
> On Dec 14, 2009, at 8:47 PM, James McLean wrote:
>
>> On Tue, Dec 15, 2009 at 10:03 AM, Philip Thompson
>> wrote:
>>> My head hurts from hitting it on my desk all day, so I thought I'd turn=
to a fresher set of eyes. The issue I'm having is getting PHP to connect O=
DBC. I can get it to work using isql from the command line. Can you verify =
my settings....:
>>>
>> [snipped]
>>>
>>> I've tried the above DSNs and many other versions of it ad nauseum. The=
specific error I'm getting is... "[unixODBC][Driver Manager]Data source na=
me not found, and no default driver specified." I really have searched high=
and low for a solution, but to no avail. Any thoughts?
>>
>> Why not just use the built in MySQL libraries or PDO?
>
> Oh, that would be "my" preference. However, the database that I really ne=
ed to connect to is an MSSQL one and the allowed connection type is ODBC. I=
was just testing first with a MySQL connection to get it working (I don't =
have the MSSQL credentials yet). Turned out I was VERY close with my soluti=
on, which a coworker figured out this morning. The [ODBC Data Sources] entr=
y for MySQL needed to specified correctly in /etc/odbc.ini.
>
> [ODBC Data Sources]
> MySQL =3D MySQL
>
> [MySQL]
> Description...
> Driver...
>
> I could have sworn I tried that, but who knows....
>
> Thank you!
> ~Philip
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

You can use a DNS-string too ...

odbc_pconnect("Driver=3D{SQL Server Native Client
10.0};Server=3D{$s_Server};Database=3D{$s_DB};MARS_Connectio n=3DYes;",
$s_User, $s_Pswd, SQL_CUR_USE_DRIVER);


--=20
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=3DZEND002498&r=3D213474=
731
ZOPA : http://uk.zopa.com/member/RQuadling

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP + ODBC

am 16.12.2009 16:07:18 von Philip Thompson

On Dec 15, 2009, at 9:50 AM, Richard Quadling wrote:

> 2009/12/15 Philip Thompson :
>> On Dec 14, 2009, at 8:47 PM, James McLean wrote:
>>=20
>>> On Tue, Dec 15, 2009 at 10:03 AM, Philip Thompson
>>> wrote:
>>>> My head hurts from hitting it on my desk all day, so I thought I'd =
turn to a fresher set of eyes. The issue I'm having is getting PHP to =
connect ODBC. I can get it to work using isql from the command line. Can =
you verify my settings....:
>>>>=20
>>> [snipped]
>>>>=20
>>>> I've tried the above DSNs and many other versions of it ad nauseum. =
The specific error I'm getting is... "[unixODBC][Driver Manager]Data =
source name not found, and no default driver specified." I really have =
searched high and low for a solution, but to no avail. Any thoughts?
>>>=20
>>> Why not just use the built in MySQL libraries or PDO?
>>=20
>> Oh, that would be "my" preference. However, the database that I =
really need to connect to is an MSSQL one and the allowed connection =
type is ODBC. I was just testing first with a MySQL connection to get it =
working (I don't have the MSSQL credentials yet). Turned out I was VERY =
close with my solution, which a coworker figured out this morning. The =
[ODBC Data Sources] entry for MySQL needed to specified correctly in =
/etc/odbc.ini.
>>=20
>> [ODBC Data Sources]
>> MySQL =3D MySQL
>>=20
>> [MySQL]
>> Description...
>> Driver...
>>=20
>> I could have sworn I tried that, but who knows....
>>=20
>> Thank you!
>> ~Philip
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>=20
>>=20
>=20
> You can use a DNS-string too ...
>=20
> odbc_pconnect("Driver=3D{SQL Server Native Client
> 10.0};Server=3D{$s_Server};Database=3D{$s_DB};MARS_Connectio n=3DYes;",
> $s_User, $s_Pswd, SQL_CUR_USE_DRIVER);

I'm actually using a combination of the DSN*-string and the odbc.ini =
settings. Thank you!

~Philip=20=

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP + ODBC

am 16.12.2009 16:22:09 von Andrew Ballard

On Tue, Dec 15, 2009 at 10:13 AM, Philip Thompson
wrote:
> On Dec 14, 2009, at 8:47 PM, James McLean wrote:
>> Why not just use the built in MySQL libraries or PDO?
>
> Oh, that would be "my" preference. However, the database that I
> really need to connect to is an MSSQL one and the allowed connection
> type is ODBC.

Is there any chance that you have to work with fields that will return
more than 4k of text? If so, you may have problems with ODBC. I can't
remember if I ever used odbc_connect() and its related functions with
SQL Server (I mostly use it to read Excel spreadsheets), but I know we
couldn't use PDO (with either the PDO_MSSQL or PDO_ODBC drivers)
because of a limit on TEXTSIZE that we couldn't get around. On our
older stuff, we're still using the mssql library, but on our newer
stuff we're using the SQL Server Driver for PHP. It connects via ODBC,
but it is the best library I've found for working with SQL Server in
PHP.


Andrew

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP + ODBC

am 16.12.2009 19:05:28 von Philip Thompson

On Dec 16, 2009, at 9:22 AM, Andrew Ballard wrote:

> On Tue, Dec 15, 2009 at 10:13 AM, Philip Thompson
> wrote:
>> On Dec 14, 2009, at 8:47 PM, James McLean wrote:
>>> Why not just use the built in MySQL libraries or PDO?
>>
>> Oh, that would be "my" preference. However, the database that I
>> really need to connect to is an MSSQL one and the allowed connection
>> type is ODBC.
>
> Is there any chance that you have to work with fields that will return
> more than 4k of text? If so, you may have problems with ODBC. I can't
> remember if I ever used odbc_connect() and its related functions with
> SQL Server (I mostly use it to read Excel spreadsheets), but I know we
> couldn't use PDO (with either the PDO_MSSQL or PDO_ODBC drivers)
> because of a limit on TEXTSIZE that we couldn't get around. On our
> older stuff, we're still using the mssql library, but on our newer
> stuff we're using the SQL Server Driver for PHP. It connects via ODBC,
> but it is the best library I've found for working with SQL Server in
> PHP.
>
>
> Andrew

So, instead of using odbc_* functions, just use the mssql_* functions?

~Philip


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php