I have xampp install in my computer and xampp php version is 5.5.15 i want to connect with a sql server (which is also install in my computer sql server 2005) i download php driver and copy paste two php file "php_pdo_sqlsrv_55_ts.dll" and "php_sqlsrv_55_ts.dll" in "C:\xampp\php\ext" folder and format php.ini file extension=php_pdo_sqlsrv_55_ts.dll and extension="php_sqlsrv_55_ts.dll" my problem is when i am restart the apache server (from xampp control panel) it's display two error message one is
httpd.exe error "http.exe error msvcp110.dll is missing from your computer"
another one is
"xampp error php startup unable to load dynamic library the specific module could not be found"
beside this error i am trying to connect with sql server using code but the code return with undefined sqlsrv_connect function error
My code is simple
<?php
$serverName='SANTUNU23-PC\SQLEXPRESS';
$connectioninfo=array ('Database'=>'DB2662_cslBeseElec');
$myuser='santunu23';
$conn=sqlsrv_connect($serverName,$connectioninfo);
if($conn)
{
echo 'connection established';
}
else
{
echo 'can not make the connection';
die(print_r(sqlsrv_errors(),TRUE));
}
?>
What to do now?any suggestion My system is windows 7 32bit
You could've googled "msvcp110.dll", then you would know that this file belongs to the "Microsoft Visual C++ 2012 Redistributable Package". So download it, install it, try it again.
Related
I am trying to connect my SQL server with PHP using Xampp. I have already uploaded dll files in the ext folder but I am unable to connect it.
My PHP version is 7.2.6.
Uploaded dll files are - php_pdo_sqlsrv_72_ts.dll, php_sqlsrv_72_ts.dll.
I have written this code to connect my SQL database with PHP-
<?php
$serverName = "INDO-SERV\SQLEXPRESS,1443";
$uid = "sa";
$pwd = "XXXXXX";
$databaseName = "web";
$connectionInfo = array("UID" => $uid, "PWD" => $pwd, "Database"=>$databaseName);
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn )
{
echo "Connection established.\n";
}
else
{
echo "Connection could not be established.\n";
die( print_r( sqlsrv_errors(), true));
}
sqlsrv_close( $conn);
?>
I am getting this error when I had tried this-
Fatal error: Uncaught Error: Call to undefined function
sqlsrv_connect() in C:\xampp\htdocs\biometric\db.php:7 Stack trace: #0
{main} thrown in C:\xampp\htdocs\biometric\db.php on line 7.
Anyone has an idea where I am doing wrong or how to connect with the database.
Installation of PHP Driver for SQL Server (sqlsrv and/or pdo_sqlsrv PHP extensions) can be done following the next steps:
Based on Microsoft PHP Drivers for SQL Server Support Matrix download appropriate version of this driver. In your case - version 5.2 or 5.3 (32-bit or 64-bit also depends on PHP version).
Download and install an appropriate ODBC driver - see System Requirements for the Microsoft Drivers for PHP for SQL Server
Load PHP Driver for SQL Server as PHP extension.
Restart Apache
Check the configuration with <?php phpinfo();?>. There should be a section with name pdo_sqlsrv (if you use PDO) and/or sqlsrv (without PDO).
my XAMPP version is 7.0.13
1- Download and Install "SQLSRV40.EXE" on this path:
D:\xampp\php\ext
2- Download and Install "msodbcsql.msi"
3- Edit file ":\xampp\php\php.ini" and add this extensions :
extension=php_sqlsrv_7_ts_x86.dll
extension=php_pdo_sqlsrv_7_ts_x86.dll
extension=php7ts.dll
4- restart xampp
Note: "SQLSRV40.EXE" Contain this extensions:
php_sqlsrv_7_ts_x86.dll , php_pdo_sqlsrv_7_ts_x86.dll , php7ts.dll
Download driver from:
https://download.microsoft.com/download/f/4/d/f4d95d48-74ae-4d72-a602-02145a5f29c8/SQLSRV510.ZIP
Unzip the files
Copy the dll files in C:\xampp\php\ext\
Open with your favourite editor the file php.ini located in C:\xampp\php\
Insert the extensions:
extension=pdo_sqlsrv_74_ts_x64
extension=sqlsrv_74_ts_x64
Restart Apache and PHP
For the new comers;
You can setup driver and integrate it as in this video explains so in a nutshell;
You should find drivers for php - sql server integration depending to your environment (versions) at links and download the driver that suits for your environment.
You should move the driver file (.dll for windows case) to php/ext folder.
You need to change php.ini as entering a new extension (for example extension=php_sqlsrv_7_ts.dll) by giving your exact file name you have moved to php/ext.
Restart your local server and you should see this extension in phpinfo(), if you can see it's there, you can connect to your db with your credentials and it's done.
Credits goes to creator of the video (applause) :)
My server is a Windows 2008 server. PHP Version 7.2.7 is installed and running. Sql Server 11 (64 bit) is installed and is working (there is a couple asp.net apps running and already using that database)
I downloaded the PHP Sql Server Drivers from Microsofts website and placed the .dll files in the PHP ext directory.
In my PHP.ini I added:extension=php_pdo_sqlsrv_7_nts_x64
In my .php file I am using to test my db connection I have:
$SqlServer = "THISSERVER\SQLEXPRESS";
$SqlServerCon = new PDO("sqlsrv:server=$SqlServer;Database=TheDatabase", "DbUName", "DbPassword");
if (!$SqlServerCon) {die('Unable To Connect to Sql Server');}
else
{echo "Connection Successful";}
I am getting:
PHP Fatal error: Uncaught PDOException: could not find driver in D:\Inetpub\wwwroot\TechStory2\DBtest.php:7 (Line 7 is the $SqlServerCon line).
What did I do wrong? and What do I need to do to get a connection to Sql Server?
I got it figured out. I had to install the ODBC Driver 17 for SQL Server (msodbcsql_17.2.0.1_x64.msi) on my server. The SQL Server Native Client 11.0 was installed but not the ODBC Driver for SQL Server.
For future reference for anyone else with this or a similar issue...
It can be downloaded at https://www.microsoft.com/en-us/download/details.aspx?id=56567 (note: if you have a 32 bit server, you will want to install the msodbcsql_17.2.0.1_x86.msi - If you accidentally try to install the incorrect version, it will let you know during the installation). After the driver is installed, you need to reboot the server. It won't prompt you to restart, but you'll need to.
In my PHP.ini I have added extension=php_pdo_sqlsrv_72_nts.dll and extension=php_sqlsrv_72_nts_x64.dll They can be downloaded at https://learn.microsoft.com/en-us/sql/connect/php/system-requirements-for-the-php-sql-driver?view=sql-server-2017
More info can be found at https://learn.microsoft.com/en-us/sql/connect/php/loading-the-php-sql-driver?view=sql-server-2017 and https://learn.microsoft.com/en-us/sql/connect/php/system-requirements-for-the-php-sql-driver?view=sql-server-2017
I can now establish a connection to Sql Server using either sqlsrv_connect or PDO.
PDO connection test:
$SqlServer = "THISSERVER\SQLEXPRESS";
$SqlServerCon = new PDO("sqlsrv:server=$SqlServer;Database=TheDatabase", "DbUName", "DbPassword");
if (!$SqlServerCon) {die('Unable To Connect to Sql Server');}
else
{echo "Connection Successful";}
sqlsrv_connect connection test:
$SqlServer = "THISSERVER\SQLEXPRESS";
$DbConnInfo = array( "Database"=>"TheDatabase", "UID"=>"DbUName", "PWD"=>"DbPassword");
$SqlServerCon = sqlsrv_connect( $SqlServer, $DbConnInfo);
if( $SqlServerCon ) {echo "Connection established";}
else
{echo "Connection could not be established.<br />";
die( print_r( sqlsrv_errors(), true));}
As commentators said - adding .dll at the end of extension= config line should be good start with your issue.
I can also see that you're trying to load NTS version of extension (NTS stands for non thread safe). Are you sure that you're going to load right version of extension? Please check if you're running PHP as NTS runtime or not - you can check it with phpinfo();.
I am having serious problem connecting to external ORA DB 11g from local Zend server CE.
OCI8 is enabled and running version 1.4.6 (due to phpinfo()).
I have tried many connection options (listed below) with the same error returned:
oci_connect(): ORA-28547: connection to server failed, probable Oracle Net admin error
After googling for whole day I am only able to say that this error means that PHP was able to comunicate with the server but was unable to connect to a concrete service/database and that the error shouldn't come from PHP itself...
I have set environment variable TNS_ADMIN to c:\oracle_instantclient_11_2 where the file tnsnames.ora is located containing this connection description:
MYDB =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = X.X.X.X)(PORT = 1521))
)
(CONNECT_DATA = (SID = MYDB)(SERVER = DEDICATED))
)
Using this description like
(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=X.X.X.X)(PORT=1521)))(CONNECT_DATA=(SID=MYDB)(SERVER=DEDICATED)))
I am able to connect to the server and the service/database with sqlplus console, so the connection is very right. I am also using the very same HOST, PORT and SID to connect to the server with Sqldeveloper tool. The problem is when connecting to the server within a PHP...
What have I tried so far:
oci_connect("user", "password", "X.X.X.X:1521", "AL32UTF8", 0);
oci_connect("user", "password", "MYDB", "AL32UTF8", 0);
oci_connect("user", "password", "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=X.X.X.X)(PORT=1521)))(CONNECT_DATA=(SID=MYDB)(SERVER=DEDICATED)))", "AL32UTF8", 0);
All of these oci_connect calls above return the same error mentioned.
I had also tried the ezconnect way for 11g as stated here - [//]host_name[:port][/service_name][:server_type][/instance_name]:
oci_connect("user", "password", "X.X.X.X:1521/MYDB", "AL32UTF8", 0);
but the problem is I do not know the service name, only the service ID (SID), thus the error returned is this:
oci_connect(): ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
that says there is no service running with the service name provided (or that the ORA listener does not know of such service).
PHP version: 5.3.14
Appache v.: 2.2.22 (32bit) Zend
Zend server CE: 5.3.6
PHP info for OCI8:
OCI8 Support enabled
Version 1.4.6
Revision $Revision: 313688 $
Active Persistent Connections 0
Active Connections 0
Oracle Instant Client Version Unknown
Temporary Lob support enabled
Collections support enabled
Directive Local Value Master Value
oci8.connection_class no value no value
oci8.default_prefetch 100 100
oci8.events Off Off
oci8.max_persistent -1 -1
oci8.old_oci_close_semantics Off Off
oci8.persistent_timeout -1 -1
oci8.ping_interval 60 60
oci8.privileged_connect Off Off
oci8.statement_cache_size 20 20
Maybe the problem is that there is unknown version of Oracle instant client though it's path is set within both the TNS_ADMIN and PATH environment variables...
My question is: does anybody know of what have I done wrong? Am I missing something? I have googled for a whole day yesterday so probably (with 99% chance) any google links You would like to provide me with I have already seen and tried...
Though this question could be considered as an exact duplicate of this one - it has not been yet answered and I guess nobody will return back to that old question even if I post a comment I am having the connection problems too. Also keep in mind that in that similar question a different error is returned and asked about.
Due to several misconfigurations and 3 days lost while looking for a solution I moved to develop on Linux server and all of the problems are gone.
What I have found:
both php_oci8.dll and php_oci8_11g.dll are depending on the Oracle Instant Client libraries
these libraries does not contain oci_ functions (like oci_connect), only ociX functions (like ociLogon) which is strange...
though I am pretty sure I have downloaded Oracle Instant Client Basic and all of the extensions, I was not able to connect to another Oracle server due to unknown charset and the error was saying I am using only Lite instant client...
I tried both 64bit and 32bit instant client version at no avail
my Apache is 64bit, windows is 64bit, PHP is 32bit, remote Oracle server is 64bit, remote Linux server is 64bit...
tried many environment settings (ORA_HOME, TNS_ADMIN, adjusted PATH to look to instant client installation) at no avail
tried uninstalling local Oracle XE server due to possible environment settings interference at no avail
almost lost my head - at no avail...
So finaly on Linux server I have no problems connecting to remote Oracle server. Somewhere (while surfing over thousands of PHP-Oracle related pages) I have found an information that "one shouldn't develop PHP application connecting to Oracle server under windows" and should stick to UNIX system instead...
So anybody experiencing similar or same problems - be so kind and do not waste Your time, install a VirtualBox, run Linux on it and move forward!
to connect php to Oracle 11g version 11.2 you need to do following;
Step-1:
login to you db with sys as sysdba and execute following scripts.
**
execute dbms_connection_pool.start_pool();
execute dbms_connection_pool.restore_defaults();
**
Step-2:
in you PHP script
**
$conn = oci_connect("username", "password", "//hostname/servicename");
if (!$conn) {
$m = oci_error();
echo $m['message'], "\n";
exit;
}
else {
print "Connected to Oracle!";
}
// Close the Oracle connection
oci_close($conn);
**
Note: i). Make sure PHP_OCI8 and PHP_OCI8_11g exertions are enabled
ii). Oracle 11 is case sensitive.
Best Regards
Yasir Hashmi
I have had the same issue and tried to connect from my local machine to a remote server.
after 2 weeks of tring I finally got it to work.
the solution is very simple but not documented in the PHP documentation
so let us take the sample PHP provided:
$conn = oci_connect('hr', 'welcome', 'localhost/XE');
what they did not mention is that it points to the default port on the server.
if yours is set up to a different one you need to specify that.
see the new example below:
$conn = oci_connect('hr', 'welcome', 'localhost:1234/XE');
try that with your specified port.
Hope this helps
Just adding my two cents, as I Banged my head against the wall with this one... If all else fails, try this, Once you have downloaded the instant client, http://www.oracle.com/technetwork/topics/winsoft-085727.html, copy it's extracted contents to the apache/bin folder. It'll likely ask you to over-write the oci.dll. Do so, then restart apache/php. With luck this will fix the problem...
Good luck.
My solution on fedora 17:
1. yum install httpd httpd-devel.
2. yum install php php-mysql php-pear php-devel
3. Install oracle instantclient:
rpm -Uvh oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm
rpm -Uvh oracle-instantclient11.2-devel-11.2.0.3.0-1.x86_64.rpm
4. pecl install oci8
This gives:
**
downloading oci8-1.4.7.tgz ...
Starting to download oci8-1.4.7.tgz (Unknown size)
.....done: 168,584 bytes
10 source files, building
running: phpize
Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
Please provide the path to the ORACLE_HOME directory.
Use 'instantclient,/path/to/instant/client/lib' if you're compiling
with Oracle Instant Client [autodetect] :'
**
Just press enter.
5. Enable the OCI8 extension by creating a file, oci8.ini for example, with the following line at /etc/php.d/:
extension=oci8.so
6. service httpd restart
For the record (PHP 8.0.12), you can also try:
In the Apache bin folder, copy inside the next files
📁 apache24
....📁 bin
....... 📃oraociei12.dll
....... 📃oci.dll
....... 📃oraons.dll
You can find those files in the Instant client folder and in the bin folder.
Then restart Apache and that is.
The instant client, apache version and PHP version must be or 32bits or 64bits.
You can also try to connect using ez-connection (if you want to avoid using the tnsnames).
phpinfo
_ENV["ORACLE_HOME"] C:\oracle\instantclient_11_2\
_ENV["OS"] Windows_NT
_ENV["Path"] C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\oracle\instantclient_11_2;\;
oci8
OCI8 Support enabled
Version 1.2.5
Revision $Revision: 1.269.2.16.2.43 $
Active Persistent Connections 0
Active Connections 0
Temporary Lob support enabled
Collections support enabled
php code
<?php
$conn = OCILogon('mppd1','mppd1', "121.256.476.86:1521/mydatabase");
$query = 'select * from users';
$stid = OCIParse($conn, $query);
//OCIExecute($stid, OCI_DEFAULT);
while ($succ = OCIFetchInto($stid, $row)) {
foreach ($row as $item) {
echo $item." ";
}
echo "<br>\n";
}
OCILogoff($conn);
?>
i am getting this error
Severity: Warning
Message: ocilogon() [function.ocilogon]: OCIEnvNlsCreate() failed. There is something wrong with your system - please check that PATH includes the directory with Oracle Instant Client libraries
I solved it copying all the content of C:\instantclient_11_2 (please check what´s yours) inside system and system32 folders in Windows , then I delete the path of C:\instantclient_11_2 in the PATH enviroment variable.
I am using XAMPP and Windows 8 and it´s the first time I see this issue. I always configured properly oci 8 with xampp and windows in a few minutes. I hope this would help you.
You need to copy all content of the instant client to apache/bin
im using xampp and working for me.
copy all files of the instant client enter image description here to apache/bin
I was facing the same error on uwamp 3 in connecting to oracle 11gR2.
I deleted the oracle instantclient from path variable and copied all files from instantclient to uwamp\bin\apache\bin
and it worked.
My setup:
System: Windows 7
Instantclient: instantclient-basiclite-win32-11.1.0.7.0
Web Server: Uwamp3
https://forums.oracle.com/forums/message.jspa?messageID=1742926#1745145
There are several potential solutions on that page ranging from re-installing xampp to checking permissions to using native php oci_connect(). Have you tried any of these things?
Probably you should download InstantClient and replace contents of /instantclient folder of Oracle client with the .dll-s of InstantClient.
I've a development computer, which runs under windows.
For a project, I've to make a php website which has to connect to an Ingres database server.
So I installed wamp, I installed ingres(server and client, on my local machine).
I added the library that I found on their site(php_ingres.dll) in the C:\wamp\bin\php\php5.3.5\ext folder, and I added a line "extension=php_ingres.dll" in the configuration file.
I shutdown wamp and restarted it, and I restarted the server, I see now a check mark in the wamp menu, indicating that php_ingres is now activated. But when I go to the welcome page of the server, I don't see this extension as loaded. If I go on the php info page, I don't see any Ingres entry in the Configure Command.
I just can't found any post/tutorial/... which indicating how to do this operation, so any help would be appreciated!
Thank you!
Edit: I made a small test to see if I can connect to an Ingres database:
<?php
$link = ingres_connect("localhost", "demodbtest", "demodbtest") or die("Connexion impossible");
echo "Connexion réussie";
$result = ingres_query($link,"select * from airline");
while ($row = ingres_fetch_array($result)) {
echo $row["al_iatacode"]; // utilisation du tableau associatif
echo $row["al_name"];
echo $row["al_ccode"]; // utilisation du tableau à indices numériques
echo "</br>";
}
ingres_close($link);
?>
And I get this error:
( ! ) Fatal error: Call to undefined function ingres_connect() in
C:\wamp\www\tests\index.php on line 2
Some information on my installation:
I've a windows 7 pro 32bits
Wampserver 2.1 ( http://sourceforge.net/projects/wampserver/files/WampServer%202/WampServer%202.1/WampServer2.1e-x32.exe/download )
Apache 2.2.17
PHP 5.3.5
Ingres 10.1.0 Community edition( downloaded here: http://esd.ingres.com/product/Community_Projects/Ingres_Database/Windows_32-Bit/Ingres_10.1_Build_121/ingres-10.1.0-121-gpl-win-x86-NoDoc.zip/http )
PHP drivers downloaded here: http://esd.ingres.com/product/drivers/PHP/Windows_32-Bit/PHP_Driver
To practically test if the extension was loaded you can as well call one of it's functions. If the extension was loaded, you should not get a fatal error for a missing function. That's perhaps one of the quickest checks.
Another check is to make use of extension_loaded *PHP Manual** which will give you a list of all loaded extensions. See the PHP Manual link above for more info.
The configure line
The configure line will not show the ingres extension because it has not been compiled in. That's perfectly alright because you load it as an extension (.dll) so it's not part of php.exe. This is why you don't see it in the configure line.
Locating ingres on the phpinfo() page.
On the phpinfo()-page use the search function inside your browser (often CTRL+F) and try to locate the word ingres. You should locate a section that displays the extensions default settings if it has been loaded.
The following is an example screenshot for the xdebug extension. This might look similar for ingres:
Image from: Launching xdebug in Eclipse stuck at 57% - How to trouble-shoot?
Double check your extension_dir setting as well as the actual php.ini file being used. Calling php.exe -i from the command line might not give the same output if executing phpinfo() in a script via Apache (or IIS). In fact http://www.wampserver.com/en/faq.php says there are 3 potential php.ini scripts.
The problem is that I wasn't having the ingres client installed locally, so it appears that this lib cannot works without it