I am trying to find out whether it is possible or not to connect to a remote Sybase server using the Sybase PHP extension and the function sybase_connect().
Actually, I cannot find any explicit answer to this question on the internet. I tried using the function like this:
$con = sybase_connect('ip:port','sa','password');
but I keep getting the error:
Warning: sybase_connect(): Sybase: Unable to connect in ...*
The server is reachable using a Sybase client such as Toad for Sybase for instance.
I am working with Windows 7 64bit and Wamp.
Would you please have any more details?
If you're using FreeTDS, I believe you need to add some settings to your freetds.conf file (mine is in /usr/local/etc/):
[ServerName]
host = 1.2.3.4
port = 1433
tds version = 8.0
"ServerName" can be anything you'd like. You should then be able to connect to it using sybase_connect('ServerName','sa','password')
Related
I try to run an ibase_connect to an firebird database.
The database is NOT on my localhost. It run on an network windows server.
I have windows too and have an connection to the shared folder:
Z:\Folder_WITH_DB.
I have XAMPP installed with
ibase extension
pdo firebird extension.
I copied the fbclient.dll into my XAMPP/php folder.
But if i run this code:
$db = 'Z:/Folder_WITH_DB/database.fdb';
$username='SYSDBA';
$password='masterkey';
$dbh = ibase_connect ( $db, $username, $password ) or die ("error in db connect");
gives this error
Warning: ibase_connect(): Unable to complete network request to host "Z". Failed to locate host machine. in xxx/index.php on line xx
firebird.log:
INET/INET_connect: gethostbyname (Z) failed, error code = 11004
I added gds_db 3050/tcp to the service file on my localhost and the server (have restarted both) and it is the same error.
Windows Firewall is deactivated on server. Service for firebird server and firebird guardian is running.
Firebird can only use a database file local to the database server. You can't connect to a Firebird database on a network share*. You need to connect to the Firebird server instead.
So if the database of 'Z:/Folder_WITH_DB/database.fdb' is on server firebirdsrv in folder D:\data\database.fdb, then you need to connect to firebirdsrv/3050:D:\data\database.fdb. I strongly suggest to remove the networkshare.
*: Technically a share can be used, but it is disabled by default because accessing a database from multiple servers through a network share can corrupt a database.
I'm trying to access to my Heroku Postgres database from a php code that runs locally.
pg_connect("host=myhost port=5432 dbname=mydb user=me password=*** sslmode=require options='--client_encoding=UTF8'")
works well when the code runs on Heroku, but not locally. (the value are those given by Heroku)
I get this error :
Unable to connect to PostgreSQL server: sslmode value "require"
invalid when SSL support is not compiled in
If I delete sslmode, I get this error :
Network is unreachable Is the server running on host "myhost" and
accepting TCP/IP connections on port 5432?
Does someone has a clue ? It would help a lot !
Heroku Postgres requires sslmode for external connections. You likely need to compile PHP with the --with-openssl[=dir] compile flag. See here for more information: http://www.php.net/manual/en/book.openssl.php
Can you verify your installation of PHP has openssl compiled in with it? The only way I know to check this is with a phpinfo() page and look for the --with-openssl flag.
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.
Does anyone know how I can install an Ms SQL extension 2005 on a Linux webserver? The webserver currently has FreeTDS library version, I have no idea on what that means. But when I try to connect it doesn't say
mssql_connect() does not exist
But it says
Unable to connect to server: xx.xx.xx.xx
I am supposing that this is because of the version of the extension since I have occured this problem on windows with ntwdblib.dll. But I don't know how to fix this on Linux.
I only need to use the functions. The database is on a windows server so I want to connect to it using mssql_connect().
The webserver is not my own it's a hosting company where I happen to know the hoster so I cannot ask him if he could install windows instead or anything. So could someone tell me how it could work for linux?
I tested it with my own pc and I can connect to the windows server from my pc. But from the webserver it doesnt, it says:
unable to connect to the server: "ip"
There are 2 parts to this:
FreeTDS... you will need to edit /etc/freetds.conf to include definition of the connection.
[CON1]
host = xxx.xxx.xxx.xxx
port = 1433
tds version = 8.0
client charset = UTF8
text size = 20971520
[CON2]
host = xxx.xxx.xxx.xxx\PIPENAME
port = 1433
tds version = 8.0
client charset = UTF8
text size = 20971520
Then, I would ignore the mssql_commands directly, and use PHP ADODB ( http://adodb.sourceforge.net/ ) to connect and run queries (especially if yoi intend to execute Stored Procs - PDO works too, but ADODB works and is reliable and consistent with SQL Server). To connect to sql server using it once you have aquired it etc:
$dbMS1=ADONewConnection("mssql");
$dbMS1->Connect('CON1','brs','TFaqAIs8');
$dbMS1->SelectDB('TheDatabase');
$sql = "SELECT .......";
$rs = $dbMS1->Execute($sql);
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.