472,958 Members | 2,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

PHP MSSQL connection problem.

mj
Hello, thanks for the help.

I am running a WinXP Pro w/ SP2 (my home computer, with ZoneAlarm
firewall)

Apache 2.0.52
MySQL 4.1.7
PHP 5.1.0-dev

I have developed a PHP/MySQL web app that tracks jobs for me, and we
use it on our peer-to-peer network. This program works GREAT :)

I also have a company website hosted remotely, where clients can place
a job request.

Win2k
IIS
MS SQL Sever 2000

On this web site we have a MSSQL database that records all the jobs
that where placed through the web site.

What I what to do know is connect to the remote MSSQL server and run
some SELECT statements with PHP.

NOW ... I can connect to the remote MS SQL sever with the client tools,
Enterprise Manager, and I can setup and connect with ODBC.

What I can't do is get php to connect to it.

- I have ntwdblib.dll in my c:\windows\system32 & c:\apache2\bin &
c:\php folders (year 2000 version)

- In SQL Sever Client Network Utility I only have TCP/IP as an "Enabled
protocols"

- I have extension=php_mssql.dll in my php.ini

- when I run:

function_exists('mssql_connect');

it returns true so I know that php_mssql.dll loaded OK

This is the code I try and connect with:

<?php

$host="mssql.dumbname.net";
$user="user";
$password="password";

mssql_connect($host,$user,$password) or die ("could not connect to
server"); // <-------- It always dies here. :(

mssql_select_db("trtrades") or die ("could not connect to DB");

....
?>

I know that the $host, $user, and $password are right because I can
connect to the remote DB with the client tools.
I also tried connect using php's ODBC functions:( I have already
created the DNS that is need)

odbc_connect($host,$user,$password) or die("can not connect to sever");
// <--------- This always dies as well

and still know luck ...
I have been working at this for a few days now, and searched all over
the net and groups for a solution to my problem with no luck.

I hope that someone might be able to help.

Cheers;

VanMan

Jul 17 '05 #1
7 23806
mj@lightfootarts.com wrote:
Hello, thanks for the help.

I am running a WinXP Pro w/ SP2 (my home computer, with ZoneAlarm
firewall)

Apache 2.0.52
MySQL 4.1.7
PHP 5.1.0-dev

I have developed a PHP/MySQL web app that tracks jobs for me, and we
use it on our peer-to-peer network. This program works GREAT :)

I also have a company website hosted remotely, where clients can place
a job request.

Win2k
IIS
MS SQL Sever 2000

On this web site we have a MSSQL database that records all the jobs
that where placed through the web site.

What I what to do know is connect to the remote MSSQL server and run
some SELECT statements with PHP.

NOW ... I can connect to the remote MS SQL sever with the client tools,
Enterprise Manager, and I can setup and connect with ODBC.

What I can't do is get php to connect to it.

- I have ntwdblib.dll in my c:\windows\system32 & c:\apache2\bin &
c:\php folders (year 2000 version)

- In SQL Sever Client Network Utility I only have TCP/IP as an "Enabled
protocols"

- I have extension=php_mssql.dll in my php.ini

- when I run:

function_exists('mssql_connect');

it returns true so I know that php_mssql.dll loaded OK

This is the code I try and connect with:

<?php

$host="mssql.dumbname.net";
$user="user";
$password="password";

mssql_connect($host,$user,$password) or die ("could not connect to
server"); // <-------- It always dies here. :(

mssql_select_db("trtrades") or die ("could not connect to DB");

...
?>

I know that the $host, $user, and $password are right because I can
connect to the remote DB with the client tools.
I also tried connect using php's ODBC functions:( I have already
created the DNS that is need)

odbc_connect($host,$user,$password) or die("can not connect to sever");
// <--------- This always dies as well

and still know luck ...
I have been working at this for a few days now, and searched all over
the net and groups for a solution to my problem with no luck.

I hope that someone might be able to help.

Cheers;

VanMan


What kind of error message do you get from your connect attempts (other
than the die messages)? Did you check the user notes in the
documentation (http://www.php.net/manual/en/functio...-connect.php)?
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 17 '05 #2
mj
Thanks for the reply Jerry. Yes I have readed ALL the user notes, and
every group I can find on this issue. I believe that other people have
had the same problem, and I followed the steps they tool to fix it ...
but still no luck :(

I don't get any kind of error message. For example when I run this
code:

<?php

....

$connt = mssql_connect($host,$user,$password);

if(!$connt)
{
$msg = mssql_get_last_message();
echo $msg;
}

....
?>

$msg if NULL.

Is there any way to tell if my mssql_connect() function is actual going
out to the remote sever and trying to connect? OR if the function is
failing on the local end?

also, these are my MSSQL setting in my php.ini file

mssql.allow_persistent = On
mssql.max_persistent = -1
mssql.max_links = -1
mssql.min_error_severity = 10
mssql.min_message_severity = 10
mssql.compatability_mode = On
;mssql.connect_timeout = 5
;mssql.timeout = 60
;mssql.textlimit = 4096
;mssql.textsize = 4096
;mssql.batchsize = 0
;mssql.datetimeconvert = On
mssql.secure_connection = On
mssql.max_procs = 25

Now, I don't know, but could there be something I need to setup in my
Apache 2's httpd.conf ?

Also I have ZoneAlarm allowing TCP on port 80, and 1433.

I would LOVE any help on this anyone can give me, even if it is only a
GOOD guess. I'm willing to try anything at this point.

Cheers;

VanMAn

Jul 17 '05 #3
mj@lightfootarts.com wrote:
Thanks for the reply Jerry. Yes I have readed ALL the user notes, and
every group I can find on this issue. I believe that other people have
had the same problem, and I followed the steps they tool to fix it ...
but still no luck :(

I don't get any kind of error message. For example when I run this
code:

<?php

...

$connt = mssql_connect($host,$user,$password);

if(!$connt)
{
$msg = mssql_get_last_message();
echo $msg;
}

...
?>

$msg if NULL.

Is there any way to tell if my mssql_connect() function is actual going
out to the remote sever and trying to connect? OR if the function is
failing on the local end?

also, these are my MSSQL setting in my php.ini file

mssql.allow_persistent = On
mssql.max_persistent = -1
mssql.max_links = -1
mssql.min_error_severity = 10
mssql.min_message_severity = 10
mssql.compatability_mode = On
;mssql.connect_timeout = 5
;mssql.timeout = 60
;mssql.textlimit = 4096
;mssql.textsize = 4096
;mssql.batchsize = 0
;mssql.datetimeconvert = On
mssql.secure_connection = On
mssql.max_procs = 25

Now, I don't know, but could there be something I need to setup in my
Apache 2's httpd.conf ?

Also I have ZoneAlarm allowing TCP on port 80, and 1433.

I would LOVE any help on this anyone can give me, even if it is only a
GOOD guess. I'm willing to try anything at this point.

Cheers;

VanMAn


VanMAn,

What about your php.log? And what's your error reporting? For
debugging like this you should have error_reporting=E_ALL.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 17 '05 #4
mj
Thanks again Jerry for the reply.

I have my error reporting set to:
error_reporting = E_ALL & ~E_NOTICE


[05-Jun-2005 02:00:11] PHP Warning: mssql_connect() [<a
href='function.mssql-connect'>function.mssql-connect</a>]: Unable to
connect to server: mssql.dumbname.net in
C:\WebServ\wwwroot\htdocs\mssql_send.php on line 12

[05-Jun-2005 02:00:21] PHP Warning: mssql_connect() [<a
href='function.mssql-connect'>function.mssql-connect</a>]: Unable to
connect to server: mssql.dumbname.net in
C:\WebServ\wwwroot\htdocs\mssql_send.php on line 12

[05-Jun-2005 02:03:42] PHP Warning: mssql_connect() [<a
href='function.mssql-connect'>function.mssql-connect</a>]: Unable to
connect to server: mssql.dumbname.net in
C:\WebServ\wwwroot\htdocs\mssql_send.php on line 12

So this what is reported in my php Error.log

Jerry do you know of any way that I can test to see if the
mssql_connect() is making it to the remote server, without have full
access to the remote server? I just what to make sure that the request
is getting there so I can narrow down where my problem is. On my side
or the remote mssql servers side. ( I think my side)

Also if you have any ideas on how I could get around this problem, if I
can't solve it would also be of get value to me. even if I have to
write a CGI script in another language.

Thanks for the help :)

Cheers;

Jul 17 '05 #5
mj
OMG .... ok I think I got it going ... ALMOST :)

I found this:

http://ca3.php.net/function.mssql-connect

and the comment by:
Ilmars Poikans in the top 1/4 of the page.

He said that he had to change his Registry to get it to work

<quote>
I'm working on Windows XP with PHP5 (should work with PHP4 also because
ntwdblib.dll is the same).

My problem was that I needed to connect to remote MS SQL server over
TCP/IP (named pipes weren't an option), but I couldn't, because named
pipes were used all the time.

One of the possible solutions is to install SQL Client Tools and
configure TCP/IP support. I hadn't SQL Server installation disk, so I
found fast solution with registry editing.

I added to registry following entry:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ MSSQLServer\Client\ConnectTo]
(strip space)
"DSQUERY"="DBNETLIB"

It worked! Just specify servername in form "host" or "host,port". I
successfully connected to remote MSSQL7 and MSSQL2000.
</quote>

So I added that value pair, and the next time I can my php code I got
this message:

Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.
could not connect to DB

So I think it is working. Now how do I tell it to use SQL Server
Authentication, not Windows Authentication ?

Once I get that working I'm cooking with gas :)

Thanks for the help

Cheers;

VanMan

Jul 17 '05 #6
mj
OMG :)

I got it working, right on !!!

So ... for anyone easy that is have the same problem, I made the follow
registry entry on my local server:

HKEY_LOCAL_MACHINE\SOFTWARE\M*icrosoft\ MSSQLServer\Client\ConnectTo]
DSQUERY=DBNETLIB

and then in my php.ini in the MSSQL area I set:

mssql.secure_connection = Off

AND IT WORK .... YES!!!

Thanks for the Help Jerry.

Cheers;

VanMan

Jul 17 '05 #7
mj@lightfootarts.com wrote:
OMG :)

I got it working, right on !!!

So ... for anyone easy that is have the same problem, I made the follow
registry entry on my local server:

HKEY_LOCAL_MACHINE\SOFTWARE\M*icrosoft\ MSSQLServer\Client\ConnectTo]
DSQUERY=DBNETLIB

and then in my php.ini in the MSSQL area I set:

mssql.secure_connection = Off

AND IT WORK .... YES!!!

Thanks for the Help Jerry.

Cheers;

VanMan


VanMan,

Glad you got it working. But I didn't help much. Just asked a few
questions - you did all the work! :-).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Antonis Konstantinos | last post by:
Hi all, My Linux (k2.4.13) machine is now working with PHP 4.3.3 with Apache 1.3.28 and Mysql 4.0.15a.. I am now writing a script that connects to a MSSQL v8.0 server. In order to do this I...
0
by: John Benson | last post by:
Thanks much for help with the Oracle db connection problem. That, plus some local assistance getting the sqlnet.ora default domain right, got everything fixed. Now I'm connected, and have been able...
0
by: dan | last post by:
Hi, I connect to a microsoft SQL server from php. Php is running on linux (debian sarge) with the freetds package. The connection is secured through stunnel (version 3.26), with stunnel running...
17
by: Danieltbt05 | last post by:
just installed SQL server 2000 and using my client , i can't locate the server. I used SQL query analyzer to search but no servers were found. Error message is as below Server : Msg17,level...
1
by: Robert Jones | last post by:
I am trying to set up an ASP site on a Windows 2003 server and am having problems connecting to the database. To isolate the problem I created a simple ASP test page which simply created an ADO...
2
by: junal | last post by:
I developed an web application using ASP.NET. i used MS SQL DB 2000. it worked fine in my local host.Kept the backup of DB when i reinstalled my win XP. problem is i insstalled .NET2005 again like b4...
2
by: dc | last post by:
I have a baffling connection problem from my C# console app to a sql server express database. The console application opens the sql database using the following code:- vDataSource = "server =...
1
by: coolminded | last post by:
hello all, i'm getting problem while connecting another mssql server. but i can connect with localhost. my connection string that runs is con.Open "Provider=SQLOLEDB.1;Integrated...
1
by: newphpcoder | last post by:
Actually, now I only test my webpage in a computer that I create as a server. And also I’m not too familiar in a server. Now I created a database in SQL Server 2005 Express and some of information I...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.