I have installed to a computer, MS SQL Server 2016 Developer Edition and created through Management Studio 17 an instance and a database. On another computer that runs IIS7, i enabled PHP extension through FastCGI and created an application.
In my application i try to run a php file with the following code:
<?php
$conn = mysql_connect('IP_OF_SQL_SERVER_INSTALLATION', 'USER_OF_SQL_DB', 'PASSWORD_OF_DB_USER', 'PORT_USED_FOR_SQL_APP')
or die('Error connecting to mysql: '.mysql_error());
?>
i wait for around 1 minute and then i get 500 - Internal server error. In SQL computer, i have enabled TCP/IP for my instance, i have opened ports 1433 (TCP) and 1434 (UDP) from windows firewall as inbound rules. Also i installed Management Studio 17 to another computer to the same network and when i try to connect from there, i get a connection. Any ideas on this?
Thank you in advance
Related
I have been fighting with Zend Server 2018 while trying to connect to a remote AS/400 DB2.
I am using the IBM_DB2 php functions to do the connection but every time I get
[IBM][CLI Driver] SQL1031N The database directory cannot be found on the indicated file system. SQLSTATE=58031 SQLCODE=-1031
Anyone else successful connecting the two?
What I've read online is that I need to catalog the servers.
So I have db2 running on an iseries at say 192.168.50.1 with a name of X232321 and a Windows 10 box running zend server 2018.
What commands would I need to catalog the two servers so I can use the db2 connector? And what does that actually do?
Thanks for the help
Try this on the windows db2 client:
db2 "catalog tcpip node MY_IS remote 192.168.50.1 server 446"
db2 "catalog db MY_ALIAS at node MY_IS"
db2 "catalog dcs db MY_ALIAS as X232321"
You can set MY_IS, MY_ALIAS as you want (no more than 8 letters).
Port 446 may be different for your iSeries host.
I just started learning PHP and MySQL, and I got stuck when trying to connect to my database from a PHP block. I have installed XAMPP and SQL Server Express 2012 on my machine. My server name is RAFAL-MAC and I selected 'Windows Authentication.'
I have a simple HTML page with PHP code in a file called search.php
the PHP code is
<?php
$con = mysql_connect('RAFAL-MAC','RAFAL-MAC\Rafal','');
if (!$con)
{
die( 'Could not connect: ' . mysql_error() ) ;
}
mysql_select_db("one", $con) or die(mysql_error());
?>
When I go to localhost:8080/search.php I get the following warning:
Warning: mysql_connect(): Host 'xxx.xxx.xxx.xxx' is not allowed to connect to this MySQL server in C:\xampp\htdocs\search_submit.php on line 11
Could not connect: Host 'xxx.xxx.xxx.xxx' is not allowed to connect to this MySQL server
I tried searching similar problems online, but all of the threads are about remote connections. I am just trying to connect to my local SQL server.
Any hints? I apologize for any missing information. Thanks! :)
EDIT:
I changed the server name to 'localhost'
Now I am getting this:
Access denied for user ''#'localhost' to database 'one'
Since you'd like to connect to SQL Server Express 2012, all functions beginning with mysql* will fail - since these functions speak to MySQL servers.
Please install Microsoft's MS SQL Server driver pack found here. From this page:
Perform the following steps to download and install the Microsoft
Drivers for PHP for SQL Server:
Download SQLSRV30.EXE to a temporary directory
Run SQLSRV30.EXE
When prompted, enter the path to the PHP extensions directory
After extracting the files, read the Installation section of the SQLSRV30_Readme.htm file for next steps
People in Microsoft's PHP driver forum should easily be able to answer your question, in case you still have problems after the installation of the driver.
Additionally, if connecting to the local machine, try to use these addresses:
localhost
127.0.0.1
These two addresses always reference the local machine.
I am using php 5.3.1 to connect to my SQL SERVER 2000 on remote machine. I use Windows XP.
On using simple program like this:
$conn = mssql_connect("VBNET","sa","mypass") or die ( 'Can not connect to server' );
I get following error:
Warning: mssql_connect() [function.mssql-connect]: message: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection. (severity 14) in C:\wamp\www\Mssql\test.php on line 8
Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: VBNET in C:\wamp\www\Mssql\test.php on line 8
Can not connect to server
I enabled TCP/IP and named pipes in my SQL SERVER and restarted it. Also its Authentication is set to Mixed Mode Authentication.
I can see my server through MS SQL Server Management Studio. So what am I missing here ?
Thanks in advance.
P.S. I have another server in SQL SERVER 2008 to which I can easily connect with the same above mentioned connection string.
EDIT: According to this post, I fired sqlcmd -S np:\\VBNET\pipe\sql\query -U sa in cmd and entered the password and that worked !!! So now what could be the problem. I am at my wits end...please help !!
If you can connect using SSMS, then copy the connection exactly, i.e. make sure you specify a named instance (e.g. 'VBNET\SQLSERVER'). Open SSMS, on the server node on the left side right click and select 'Properties'.
If you have SQL 2008 running on the same machine it is most likely that SQL 2008 uses the default instance and SQL 2000 a named instance.
What also could help, i.e. make testing simpler is to create an empty UDL file (e.g. 'TEST.UDL'). An empty text file should do. Then double click on it, select the provider and play around with the settings. You can always test the connection using the 'Test connection' button. I use this trick when I have to connect from a customer PC for the first time.
I am having issues connecting to a mssql server that is located on a network machine. I need to connect remotely through another domain example (abc.com) not on the network to access data. This domain runs mysql if that makes any difference. I am trying to access the mssql server through this php script:
<?php
$server= 'ip address:port';
$user='user';
$password= 'pass';
$con = mssql_connect($server,$user,$password);
if (!$con)
{
die('Could not connect:' . mssql_get_last_message() );
}
else{ echo 'connected';
}
I run this script through the shell on abc.com and I get:
mssql_connect(): Unable to connect to server:
I have gone through several tutorials to enabling tcp/ip access through the sql server config manager as well as allowing the specific port through the firewall.
What are some other things I should try or steps I am missing here.
Also: the ip address I am using is the one I found in the sql server config manager-> protocols for SQLEXPRESS->tcp/ip_>ip addresses->IP2->ip adress it is the correct ip address? Where can I find it if not? I am not using the localhost 127.0.0.1
In short to successfully execute the cmd.
config:
(2 instances of SQL // SQL2005 + 2008 Express instance on the remote machine, which refuses to install Management Studio 2008.
1. Enable TCP/IP Protocol
2. Enable Named Piptes
3. started sqlcmd Utility with -s \SQLEXPRESS to get the right sever-instance
C:\Program Files\Microsoft SQL Server\100\Tools\Binn
4. Go to SMSS and local sql instance properties -> Connections -> check "Allow remote connections to this server" and run this script.
EXEC sys.sp_configure N'remote access', N'1'
GO
RECONFIGURE WITH OVERRIDE
GO
Here the link for the info from Msdn:
http://msdn.microsoft.com/en-us/library/ms162773.aspx
http://msdn.microsoft.com/en-us/library/ms162816.aspx
Thanx
We are using MSSQL server 2008 on Win server 2008 R2 and have installed Apache (2.2.19) and PHP (5.2.17) separately. We have installd the MSSQL module for PHP and usingthe following connection string:
$myc = mssql_connect(Server, SiteDatabaseUsername, SiteDatabasePassword) or die('Can\'t connect to mssql Database Server: '.mssql_get_last_message($myc));
$db = mssql_select_db(SiteDatabaseName, $myc) or die('Can\'t find database: '.mssql_get_last_message($myc));
But it gives us this error:
Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: localhost\MSSQLSERVER in D:\Apache2.2\htdocs\adminarea\_core.php on line 89
Can't connect to mssql Database Server:
We have used the IP:PORT, localhost\MSSQLSERVER and COMPUTERNAME\MSSQLSERVER but don't seem to be getting anywhere, can anyone help please?
A few things come to mind:
1) Make sure you have the sqlsrv driver package from MS, and make sure you're loading it properly in php.ini (use phpinfo() to verify).
2) If this was a vanilla installation of SQL Server, its likely that only windows authentication is turned on. Open the SQL Enterprise Manager and make sure you have SQL Server Authentication enabled on your database.
3) Make sure that you have enabled network access to SQL Server. I'm not immediately certain whether the new MS drivers use named pipes to communicate with the server, or if they expect that the server will be accessed via the network.
These are the issues I routinely encounter when getting PHP speaking to a new MSSQL server.