473,761 Members | 1,808 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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\syst em32 & 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_m ssql.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.du mbname.net";
$user="user";
$password="pass word";

mssql_connect($ host,$user,$pas sword) 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($h ost,$user,$pass word) 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 23873
mj@lightfootart s.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\syst em32 & 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_m ssql.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.du mbname.net";
$user="user";
$password="pass word";

mssql_connect($ host,$user,$pas sword) 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($h ost,$user,$pass word) 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*******@attgl obal.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,$pas sword);

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_per sistent = On
mssql.max_persi stent = -1
mssql.max_links = -1
mssql.min_error _severity = 10
mssql.min_messa ge_severity = 10
mssql.compatabi lity_mode = On
;mssql.connect_ timeout = 5
;mssql.timeout = 60
;mssql.textlimi t = 4096
;mssql.textsize = 4096
;mssql.batchsiz e = 0
;mssql.datetime convert = On
mssql.secure_co nnection = 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@lightfootart s.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,$pas sword);

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_per sistent = On
mssql.max_persi stent = -1
mssql.max_links = -1
mssql.min_error _severity = 10
mssql.min_messa ge_severity = 10
mssql.compatabi lity_mode = On
;mssql.connect_ timeout = 5
;mssql.timeout = 60
;mssql.textlimi t = 4096
;mssql.textsize = 4096
;mssql.batchsiz e = 0
;mssql.datetime convert = On
mssql.secure_co nnection = 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*******@attgl obal.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'>functi on.mssql-connect</a>]: Unable to
connect to server: mssql.dumbname. net in
C:\WebServ\wwwr oot\htdocs\mssq l_send.php on line 12

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

[05-Jun-2005 02:03:42] PHP Warning: mssql_connect() [<a
href='function. mssql-connect'>functi on.mssql-connect</a>]: Unable to
connect to server: mssql.dumbname. net in
C:\WebServ\wwwr oot\htdocs\mssq l_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_MACH INE\SOFTWARE\Mi crosoft\ MSSQLServer\Cli ent\ConnectTo]
(strip space)
"DSQUERY"="DBNE TLIB"

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\ANONY MOUS 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_MACH INE\SOFTWARE\M* icrosoft\ MSSQLServer\Cli ent\ConnectTo]
DSQUERY=DBNETLI B

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

mssql.secure_co nnection = Off

AND IT WORK .... YES!!!

Thanks for the Help Jerry.

Cheers;

VanMan

Jul 17 '05 #7
mj@lightfootart s.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_MACH INE\SOFTWARE\M* icrosoft\ MSSQLServer\Cli ent\ConnectTo]
DSQUERY=DBNETLI B

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

mssql.secure_co nnection = 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*******@attgl obal.net
=============== ===
Jul 17 '05 #8

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

Similar topics

1
2102
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 want to use PHP. Then I have installed FreeTDS and tested its script on the command line and it works fine. When I write a piece of php line, my web server returns me that "Call to undefined function: mssql_connect()"
0
1513
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 to retrieve information from Oracle into my PC Python session. I seem to see a lot of advice asking people to google before submitting a problem to the list. This was nicely illustrated by the suggestion to google on the verbatim Oracle...
0
2215
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 locally on the web server and locally on the SQL server machine. This means php connects locally to the stunnel port, which then establishes a secure connection to stunnel on the sql server. There the data is then transmitted locally to the SQL...
17
9239
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 16, state1 SQL server does not exist or denied access.
1
1738
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 connection object, connected to the database and returned some results. When I ran the code as a VBS file it worked fine, but when I run it as an ASP page (obviously with slight adjustments such as replacing MsgBox with Response.Write etc) it...
2
1324
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 n gave the same name of DB....i mean everything was same as b4.....but when i went to run my application it shows connection problem. why is that ?.....could anybody help me plz?
2
2632
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 = " + vgSqlServer + "; " + "database = " + vgSqlServerDb + ";" + "uid = XXX; pwd = XXX; ";
1
1504
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 Security=SSPI;Password=admin123;Persist Security Info=True;" & _ "User ID=sa;Initial Catalog=dtbs;Data Source=MYCOMPUTER\SQLEXPRESS"
1
1929
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 will share is: I also used: SQL Server 2005 Express IIS 6.0 php 5.2.14 Server Type: Database Engine Server name: ComputerName\SQLEXPRESS Authentication: Windows Authentication
0
9554
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9377
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10136
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9811
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5266
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3913
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3509
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.