ellandrd
asked on
URGENT connect to SQL server
im trying to connect to SQL server in our office using PHP.
im currently logged onto the network and all of our websites including PHP and IIS is installed on our SERVER01.
our SQL SERVER is installed on SERVER04 but does not have PHP or IIS installed on it. I can get a connection suing ODBC's DSN configuration, but i dont know how to do this in PHP and query table
i have enabled php_msql.dll on SERVER01 but i get
Fatal error: Call to undefined function mssql_connect() in c:\Inetpub\wwwroot\admin\P ersonal\in dex.php on line 10
if i check the php.ini setting SQL is supported so im confused... my SERVER01 is windows 2000....
code:
echo (mssql_connect("Personell" ,"ellanndr d","")) ? "YES": "NO";
im currently logged onto the network and all of our websites including PHP and IIS is installed on our SERVER01.
our SQL SERVER is installed on SERVER04 but does not have PHP or IIS installed on it. I can get a connection suing ODBC's DSN configuration, but i dont know how to do this in PHP and query table
i have enabled php_msql.dll on SERVER01 but i get
Fatal error: Call to undefined function mssql_connect() in c:\Inetpub\wwwroot\admin\P
if i check the php.ini setting SQL is supported so im confused... my SERVER01 is windows 2000....
code:
echo (mssql_connect("Personell"
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
>>how?
i uncommented it.
my php.ini lives in c:\winnt\php.ini
i have copied msql.dll into winnt folder and system32 too...
>>Have you restarted the server after enabling msql.dll?
im in a office full of engineers all working off the server01 so its isnt really possible until...
php_mssql.dll & php_msql.dll is there a different? Mmmm hold on i might i selected the wrong one...
i uncommented it.
my php.ini lives in c:\winnt\php.ini
i have copied msql.dll into winnt folder and system32 too...
>>Have you restarted the server after enabling msql.dll?
im in a office full of engineers all working off the server01 so its isnt really possible until...
php_mssql.dll & php_msql.dll is there a different? Mmmm hold on i might i selected the wrong one...
ASKER
am annoyed - i have php_msql.dll uncommented not php_mssql.dll...
let me try my code again and i'll get back to you...
let me try my code again and i'll get back to you...
>php_mssql.dll & php_msql.dll is there a different? Mmmm hold on i might i selected the wrong one...
yes, they are different. please enable php_mssql.dll and try again
yes, they are different. please enable php_mssql.dll and try again
ASKER
OK better progress made - now im getting:
Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: SERVER04 in c:\Inetpub\wwwroot\admin\P ersonal\in dex.php on line 10
NO
Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: SERVER04 in c:\Inetpub\wwwroot\admin\P
NO
ASKER
my ODBC DSN pointer is called: Personell and it can connect to SQL server OK, but it in PHP that i need to get working,..
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok SQL server name is FILE04COMPANYNAME
so my code will be:
mssql_connect("FILE04COMPA NYNAME","u ser","pwd" )
??
whats this boolean link thingy at the end? what goes there?
so my code will be:
mssql_connect("FILE04COMPA
??
whats this boolean link thingy at the end? what goes there?
you can ignore that for the moment (optional parameter)
ASKER
well it still dont work...
ASKER
the database im trying to access it highlighted:
www.seandelaney.co.uk/ee.bmp
the name of the server SQL is installed on is \\SERVER04
still not working
code:mssql_connect("FILE04 ABZPI,1433 ","adminis trator","p wd")
www.seandelaney.co.uk/ee.bmp
the name of the server SQL is installed on is \\SERVER04
still not working
code:mssql_connect("FILE04
ASKER
ok guys i still dont have it working! i need more help - i have never played with SQL server before - so i dont know how to work it or connect to it...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: SERVER04 in c:\Inetpub\wwwroot\admin\P ersonal\in dex.php on line 10
ASKER
IP address of server01 (PHP and IIS is installed) is 192.168.0.2
IP address of server04 (SQL server is installed) is 192.168.0.5
my code:
echo (mssql_connect("192.168.0. 5","admini strator"," xxxx")) ? "YES": mssql_get_last_message();
dont work either...
IP address of server04 (SQL server is installed) is 192.168.0.5
my code:
echo (mssql_connect("192.168.0.
dont work either...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
>>telnet 192.168.0.5 1433
TELNET dialog appear but nothing is happening... no message appearing...
i will search for client tool...
TELNET dialog appear but nothing is happening... no message appearing...
i will search for client tool...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i get
Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: 192.168.0.5 in c:\Inetpub\wwwroot\admin\P ersonal\in dex.php on line 12
Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: 192.168.0.5 in c:\Inetpub\wwwroot\admin\P
ASKER
from the client tool i get this:
Server Error in '/webadmin' Application.
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
Impersonation failure.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Impersonation failure.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): Impersonation failure.]
System.Web.ImpersonationSu spendConte xt.GetCurr entToken() +197
System.Web.ImpersonationSu spendConte xt.Suspend () +53
System.Web.HttpContext.Get Config(Str ing name) +104
System.Web.CustomErrors.Ge tSettings( HttpContex t context, Boolean canThrow) +19
System.Web.HttpResponse.Re portRuntim eError(Exc eption e, Boolean canThrow) +39
System.Web.HttpRuntime.Fin ishRequest (HttpWorke rRequest wr, HttpContext context, Exception e) +485
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
does this mean im connected but there another problem?
Server Error in '/webadmin' Application.
--------------------------
Impersonation failure.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Impersonation failure.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): Impersonation failure.]
System.Web.ImpersonationSu
System.Web.ImpersonationSu
System.Web.HttpContext.Get
System.Web.CustomErrors.Ge
System.Web.HttpResponse.Re
System.Web.HttpRuntime.Fin
--------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
does this mean im connected but there another problem?
is "administrator" a login you created in the SQL Server LOGINS ?
ASKER
i didnt create it? i assume the username and password was that of the admin account for the whole network? no?
>i assume the username and password was that of the admin account for the whole network? no?
in sql server, you have to explicitely create the logins you want to grant access to for connection.
I am not sure about php (did not try that yet) if it allows windows authentication, but I doubt.
you should create a SQL Logins, grant it permissions in the Personnel database, and use that login+password in the connection
in sql server, you have to explicitely create the logins you want to grant access to for connection.
I am not sure about php (did not try that yet) if it allows windows authentication, but I doubt.
you should create a SQL Logins, grant it permissions in the Personnel database, and use that login+password in the connection
ASKER
ok i will try that.. but how?
i mean for "you should create a SQL Logins"? how?
i mean for "you should create a SQL Logins"? how?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OK i created new login and set up password and selected personnel database. grant access was already selected so i left it alone...
i'll try connecting again so i'll brk
i'll try connecting again so i'll brk
ASKER
I still get unable to connect to server: SERVER04.
here is printscreen of the instance...
http://www.seandelaney.co.uk/mssql.JPG
here is printscreen of the instance...
http://www.seandelaney.co.uk/mssql.JPG
>SERVER04
the screenshot shows FILE04ABZPI and not SERVER04 ?!
what is this name of SERVER04?
please try to connect using the FILE04ABZPI name instead...
the screenshot shows FILE04ABZPI and not SERVER04 ?!
what is this name of SERVER04?
please try to connect using the FILE04ABZPI name instead...
ASKER
the server mssql is installed on.
i have done so and still get same message
i have done so and still get same message
and what is the name FILE04ABZPI shown in the screenshot?
ASKER
is that not the name of mssql? i have never set up connections before or used mssql. this is my first time and i was asked to connect to mssql using php as apart of a task...
what is the output of (from dos command line):
PING FILE04ABZPI
PING SERVER04
PING FILE04ABZPI
PING SERVER04
ASKER
here is another print screen - maybe this is more help.. as im getting confused
http://www.seandelaney.co.uk/mssql2.JPG
http://www.seandelaney.co.uk/mssql2.JPG
ASKER
http://www.seandelaney.co.uk/pingfile04abzpi.JPG
pinging server04 nothing happen - could not find host...
pinging server04 nothing happen - could not find host...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
>>in the service manager window, what is listed in the "server" list?
there is load of items listed...
http://www.seandelaney.co.uk/list.JPG
>>in the enterprise Manager, I see that you have a BKUPEXEC instance on that server, possibly (local) represents the default instance?
i dont know what BKUPEXEC is - i assume my boss set this up to carry out backups....
the database i need to access is called "Personnel" and as you can see it is in default instance (local)(NT Windows).
>>what are the properties of (local) in the enterprise Manager?
when i do this, i get a dialog with lots of tabs - what info are you looking for?
there is load of items listed...
http://www.seandelaney.co.uk/list.JPG
>>in the enterprise Manager, I see that you have a BKUPEXEC instance on that server, possibly (local) represents the default instance?
i dont know what BKUPEXEC is - i assume my boss set this up to carry out backups....
the database i need to access is called "Personnel" and as you can see it is in default instance (local)(NT Windows).
>>what are the properties of (local) in the enterprise Manager?
when i do this, i get a dialog with lots of tabs - what info are you looking for?
ASKER
in the enterprise manager, the (local) sql server. when i expand the folder called Security and views subfolders:
Logins
Server Roles
Linked Servers
Remote Servers
under remote servers its name is FILE04ABZPI...
my PHP page exists on a different server than where the MS SQL server is on - you know this right? (as i said this at the start of the question...)
Logins
Server Roles
Linked Servers
Remote Servers
under remote servers its name is FILE04ABZPI...
my PHP page exists on a different server than where the MS SQL server is on - you know this right? (as i said this at the start of the question...)
well, the connection with FILE04ABZPI should then work, can you show me how you defined the login?
ASKER
what do you mean?
my code
my code
no, in the Enterprise Manager, under LOGINS you did create a login. please show me that form of that login
ASKER
<?php
$server = "file04abzpi";
$username = "sd";
$password = "???????";
$sqlconnect = mssql_connect($server, $username, $password);
#$sqldb = mssql_select_db("Personnel ",$sqlconn ect);
#$sqlquery = "SELECT firstName FROM tblPersonnel;";
#$results = mssql_query($sqlquery);
#while ($row = mssql_fetch_array($results ))
#{
# echo $row['firstName']."<br>\n" ;
#}
#mssql_close($sqlconnect);
?>
$server = "file04abzpi";
$username = "sd";
$password = "???????";
$sqlconnect = mssql_connect($server, $username, $password);
#$sqldb = mssql_select_db("Personnel
#$sqlquery = "SELECT firstName FROM tblPersonnel;";
#$results = mssql_query($sqlquery);
#while ($row = mssql_fetch_array($results
#{
# echo $row['firstName']."<br>\n"
#}
#mssql_close($sqlconnect);
?>
ASKER
any luck?
can you show the database tab on the same form, please
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
osql not recognised... ive tried this on my machine OK? do i do this on the FILE04ABZPI server?
ASKER
if i do it on FILE04ABZPI
ASKER
sorry pages submitted for some reason...?
if i do it on file04abzpi, its like it freezes and does nothing?
if i do it on file04abzpi, its like it freezes and does nothing?
does it give you a command prompt like (SQL>)?
possibly post the screenshot.
possibly post the screenshot.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
>>assuming that at least the sql client tools are installed
no client tools is installed on the server where PHP is!
no client tools is installed on the server where PHP is!
ASKER
the tool was installed on my laptop...
well, then please try the new osql as posted from your laptop
ASKER
i get "osql" not recognised
You just said it was installed on you laptop
ASKER
yes and i cant connect to personnel database fine and query it but not using PHP...
the tool used OBDC DSN though... as ive one set up...
the tool used OBDC DSN though... as ive one set up...
ASKER
the command osql -Sfile04abzpi -Usd -P<password> dont work - i get osql not recognised...
ASKER
taken from another question asked:
https://www.experts-exchange.com/questions/20814437/php-connect-sql-server2000-windows-2000-server.html
Extract below:
>>from the manual:
>>The extension requires the MS SQL Client Tools to be installed on the system where PHP is installed. The Client >>Tools can be installed from the MS SQL Server CD or by copying ntwdblib.dll from \winnt\system32 on the server to >>\winnt\system32 on the PHP box. Copying ntwdblib.dll will only provide access. Configuration of the client will require >>installation of all the tools.
do i need to copy ntwdblib.dll from FILE04ABZPI to our server where PHP is installed as i done a search on our server (MAIL01ABZPI) where PHP is installed and i cant find that file. if i search for it on FILE04ABZPI i can find it...
https://www.experts-exchange.com/questions/20814437/php-connect-sql-server2000-windows-2000-server.html
Extract below:
>>from the manual:
>>The extension requires the MS SQL Client Tools to be installed on the system where PHP is installed. The Client >>Tools can be installed from the MS SQL Server CD or by copying ntwdblib.dll from \winnt\system32 on the server to >>\winnt\system32 on the PHP box. Copying ntwdblib.dll will only provide access. Configuration of the client will require >>installation of all the tools.
do i need to copy ntwdblib.dll from FILE04ABZPI to our server where PHP is installed as i done a search on our server (MAIL01ABZPI) where PHP is installed and i cant find that file. if i search for it on FILE04ABZPI i can find it...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
it worked!
ASKER
i cant believe this - it worked.... excellent! can eat now and pull myself out from this chair...
ASKER
thank you!
Glad I could help you, took some time to get this working indeed.
ASKER
yes i know, but we didnt give up...
how?
usually, the php.ini file is the one in the windows folder...