on 02-17-2015 10:32 AM
Hello,
please help with the following php odbc_connect problem:
On my local machine (win 7, 64 bits) is a running SQL Anywhere 16 database. Started with
dbeng16.exe -c 8m -n xx_test "G:\DEMOS\xx\DB16\test.db"
In the ODBC manager then created a ODBC connection (xxdsn).
But the connection from PHP 5.3.8 fails:
$verbindung = odbc_connect('xxdsn', 'dba', 'sql');
It shows
Warning: odbc_connect() [function.odbc-connect]: SQL error: [Sybase][ODBC Driver][SQL Anywhere]Datenbankserver nicht gefunden, SQL state 08001 in SQLConnect in verbindung.php on line 4
The database is definitively runnig. Tested by opening an odbc connection from isql.
When I create an odbc connection on a database file, I can make an php odbc_connect.
This problem is only on the Win 7 machine and also with SQL Anywhere 12.
When I try the same on a (32 bits) XP machine it runs fine.
Please help, to find my mistake.
Thanks in advance!
Best regards,
Peter
When you are connecting with PHP, are you simply running a PHP application, or is this through Apache? If it's Apache, the Apache server is running as a service. On XP, this was not a problem. But starting with Vista, a shared memory connection from a service could not connect to a server that was NOT running as a service, and vice versa. This is why it works on the XP machine and not on Windows 7.
You need to enable TCP/IP on your engine using "-x tcpip" and add "HOST=localhost" to the connection string used by PHP.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Peter,
Do you mean that you can use the same DSN (xxdsn) to connect to your database server using InteractiveSQL?
Are you using PHP 32-bit?
Have you created that DSN using ODBC DSN manager 32 bit version C:\Windows\SysWOW64\odbcad32.exe ?
Mirco
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mirco,
thanks for your answer.
Do you mean that you can use the same DSN (xxdsn) to connect to your database server using InteractiveSQL?
Yes, first I've started the DB and then I've conneted Interactive SQL by selecting an odbc datasource.
Are you using PHP 32-bit?
No, phpinfo(); tells me 5.3.8-Win64.
Have you created that DSN using ODBC DSN manager 32 bit version C:\Windows\SysWOW64\odbcad32.exe ?
No I've used ODBC manager 64 bit version. C:\Windows\System32\odbcad32.exe
I don't know, what to do.
Thanks in advance - Peter
Please review the following Getting Started with SAP SQL Anywhere and PHP - SAP SQL Anywhere - SCN Wiki
There is also a troubleshooting session.
Mirco
Also, have a look at PHP: odbc_connect - Manual
There is an example for SQL Anywhere. It is called "SQL Server Anywhere 8.0 on Windows". It still uses odbc_connect but with a more detailed connection string.
Mirco
Hi Mirco,
thank you very much for your hints. Sorry for my late reaction, yesterday I was out of office, but I've tested a lot of hours without success. Meanwhile I have an identical environment on tow different pc's (Win 7 64 bit and XP 32 bit):
Apache 2.2.21
PHP 5.3.8
SA 16 db file xx_16.db
On both machines is a running server: dbeng16.exe -c 8m -n xxx "G:\DEMOS\DB\xxx_16.db"
On both machines I can send a ping on the running db:
dbping -d -c "Server=xxx;DBN=xxx_16;UID=DBA;PWD=sql"
C:\Users\peter>dbping -d -c "Server=xxx;DBN=xxx_16;UID=DBA;PWD=sql"
SQL Anywhere-Dienstprogramm Server-Ping Version 16.0.0.1948
Verbunden mit SQL Anywhere 16.0.0.1948 Server "xxx" und Datenbank "xxx_16".
Ping der Datenbank erfolgreich.
On the 32 bit XP(SP3) the following script runs succsessfull:
$connect_string = "Driver={SQL Anywhere 16};ServerName=kww;DatabaseName=kww_16;uid=dba;pwd=sql";
$conn = odbc_connect($connect_string,'','');
if($conn)
{
echo "okay";
}
else
{
echo "fehler";
}
Not so on Windows 7. There is still the error message "... databaseserver not found..."
Btw, I CAN connect with a database by starting with
$conn = odbc_connect('dsnname', 'dba', 'sql');
But I still can't connect with a running db.
Best Regards,
Peter
Hi Peter,
Can you try to specify LogFile connection parameter in the connect_string, reproduce and check the content of the log file for any hints please?
I am also wondering if specifying the IP address of your machine using the HOST parameter makes any difference.
Thank you,
Mirco
The command line you use to start the database server is:
dbeng16.exe -c 8m -n xxx "G:\DEMOS\DB\xxx_16.db"
That means that the connection parms should be
ServerName=xxx
DatabaseName=xxx_16
The connection parameters for dbping uses connection parm values that correctly match the start command for the database server. However, the connection string used by PHP uses
ServerName=kww
DatabaseName=kww_16
Hi Mirco,
thank you for your time. Here both log files.
From XP:
Donnerstag, 19. Februar 2015 15:03:4
15:03:42 Verbindungsversuch mit:
UID=dba;PWD=********;DBN=xxx_16;ServerName=xxx;CON=SQL_DBC_4224f48;LOG=C:\temp\sybase.log
15:03:42 Verbindungsversuch mit einem laufenden Server...
15:03:42 SharedMemory-Verbindung wird versucht (keine im Cache sasrv.ini gespeicherte Adresse)
15:03:42 Verbunden mit Server über SharedMemory
15:03:42 Verbunden mit SQL Anywhere Server Version 16.0.0.1324
15:03:42 Hinweise zur Anwendung:
15:03:42 IP=192.168.178.24;HOST=COMPAREX;OSUSER=SYSTEM;OS='Windows XP Build 2600 Service Pack 3';EXE=E:\apps\OSGeo\mgos251\Web\Apache2\bin\httpd.exe;PID=0x250;THREAD=0x2d4;VERSION=16.0.0.1324;API=ODBC;TIMEZONEADJUSTMENT=60
15:03:42 Verbunden mit dem Server, Verbindung mit einer laufenden Datenbank wird versucht...
15:03:42 [ 2] Verbindung mit der Datenbank erfolgreich eingerichtet
15:03:43 [ 2] Verbindung zum Server getrennt
From Win 7 (PHP connection):
Donnerstag, 19. Februar 2015 14:48:23
14:48:23 Verbindungsversuch mit:
UID=dba;PWD=********;DBN=xxx_16;ServerName=xxx;CON=SQL_DBC_293610;LOG=c:\temp\sybase.log
14:48:23 Verbindungsversuch mit einem laufenden Server...
14:48:23 SharedMemory-Verbindung wird versucht (keine im Cache sasrv.ini gespeicherte Adresse)
14:48:23 Kein benannter Puffer des gemeinsam genutzten Speichers gefunden
14:48:23 Es wird nicht versucht, einen Server automatisch zu starten
14:48:23 Verbindung mit dem Server nicht möglich
But trying to start ianywhere on Win 7 machine with
dbisql -c "DSN=xxxdsn;LOG=c:\logs\test.txt"
shows this log:
Donnerstag, 19. Februar 2015 15:49:27
15:49:27 Verbindungsversuch mit:
UID=dba;PWD=********;ServerName=xxx;CON=SQL_DBC_5d09b6f0;INT=NO;LOG=c:\temp\sybase.log
15:49:27 Verbindungsversuch mit einem laufenden Server...
15:49:27 Start der SharedMemory-Verbindung wird versucht ...
15:49:27 SharedMemory-Verbindung erfolgreich gestartet
15:49:27 SharedMemory-Verbindung wird versucht (keine im Cache sasrv.ini gespeicherte Adresse)
15:49:27 Verbunden mit Server über SharedMemory
15:49:27 Verbunden mit SQL Anywhere Server Version 16.0.0.1948
15:49:27 Hinweise zur Anwendung:
15:49:27 IP=192.168.178.37;HOST=peterhp;OSUSER=peter;OS='Windows 7 Build 7601 Service Pack 1';EXE=C:\apps\asa16_64bit\bin64\dbisql.exe;PID=0x2410;THREAD=0x24c4;VERSION=16.0.0.1948;API=iAnywhereJDBC;TIMEZONEADJUSTMENT=60
15:49:27 Verbunden mit dem Server, Verbindung mit einer laufenden Datenbank wird versucht...
15:49:27 [ 2] Verbindung mit der Datenbank erfolgreich eingerichtet
15:49:27 [ 2] Anzahl der abgerufenen Zeilen reduziert auf 16 entsprechend der
15:49:27 [ 2] Abrufpufferbegrenzung. Verbindungsparameter 'PrefetchBuffer' kann Performance verbessern.
When I try to use the HOST parameter, the connection fails. However both machines running local.
Thank you too,
Peter
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.