XAMPP ORACLE - TNS:could not resolve the connect identifier specified - php

I am using Xampp on Windows 8 64 bit and using Oracle 11g Express Edition Command line.
I did uncomment oci8 extension on php.ini files restart Apache n i am using correct password my php code is
<?php
$conn = oci_connect('system','asd','locahost/XE');
?>
but i am getting this error
ORA-12154: TNS:could not resolve the connect identifier specified in C:\xampp\htdocs\am\index.php on line 2
but on other pc with windows 7 its working correctly.
My command line sql is running perfectly but php connection is not establishing.
Note:
when i was installing oracle on this pc (win8) i got an error as
The installer is unable to instantiate the file C:\Users\McLAUGH~1\AppData\Local\Temp{078E83D7-3FCC-4A72-903B-995C7CE44681}\KEY_XE.reg. The file does not appear to exist.
but i did press ok n everything seems to be fine but now this problem is happening please help me. Thanks

For the error you mentioned, please go throught the following link and follow the steps mentioned in it and try if your issue get resolved.
http://blog.mclaughlinsoftware.com/tag/install-oracle-11g-release-xe/

Related

Installing on XAMPP PHP7.4.11 SQLSRV drivers [duplicate]

I trying to connect to an SQL Server in PHP. With XAMPP on my local machine, everything works well. But now I going to bring my application on the production server.
On this server there is installed the Microsoft IIS 6.1 and running the PHP version 7.0.7. I also installed the ODBC Driver from here. Next I decomment the following line in my php.ini file:
extension=php_sqlsrv_7_nts.dll
extension=php_pdo_sqlsrv_7_nts.dll
I got the files from the official microsoft site.
What's my problem?
Unfortunately, after I restarted the IIS. The PDO function throws the PDOException error with the following message:
could not find driver
For the connection I am using the following function which works pretty well on my local machine:
try {
$con = new PDO("sqlsrv:Server=" . SERVER . ";Database=" . DATABASE, USERNAME, PASSWORD);
// set the PDO error mode to exception
$con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
echo "No connection: " . $e->getMessage();
exit;
}
What can I else do?
Here is detailed process if it's helpful for someone. PHP Version - 7.4
Download and extract the .dll files from this link - https://learn.microsoft.com/en-us/sql/connect/php/download-drivers-php-sql-server?view=sql-server-ver15
Paste the files in C:\xampp\php\ext, your path could be different.
in php.ini add those two lines at bottom or in extension section.
extension=php_sqlsrv_74_ts_x64.dll
extension=php_pdo_sqlsrv_74_ts_x64.dll
Restart your Xampp server, I'll suggest restart your computer and everything will work without an issue then.
Check if SqlSRV enabled
Check using phpinfo() or http://localhost/dashboard/phpinfo.php at like this -
Hope, it will help someone.
After I found the error log on the Windows Server, I solved the error by myself.
I got this error in my log:
[21-Apr-2017 07:12:14 UTC] PHP Warning: PHP Startup: Unable to load dynamic library '...\ext\php_pdo_sqlsrv_7_nts.dll' - %1 is not a valid Win32 application. in Unknown on line 0
Then I downloaded again the driver and installed the x64-Driver. Finally It works without any problems.
please notice you must use the correct version of php_sqlsrv_xx_xts_xxx.dll and php_pdo_sqlsrv_xx_xts_xx.dll files.
for exmple if you use php version 7.4 and a 64 bit system and wamp you must download and use these files:
php_sqlsrv_74_ts_x64.dll
php_pdo_sqlsrv_74_ts_x64.dll
for download you can use this site:
https://go.microsoft.com/fwlink/?linkid=2152937
https://learn.microsoft.com/en-us/sql/connect/php/download-drivers-php-sql-server?view=sql-server-ver15
It took some time for me to solve the 'No driver'-error. I went through some steps as mentioned here and found some other ones that helped me after new errors. For future references:
Download the latest drivers from Microsoft (as said by Julian Schmuckli).
Check if your XAMPP is 64 bits(!) with Phpinfo(). If you've got 32-bit, you need different drivers.
Add the drivers to your Php.ini file and save the dll's in your php/ext-folder (question of saber tabatabaee yazdi).
For the connection, use this code:
$dbh = new PDO ("sqlsrv:Server=$server;Database=$dbname",$username,$pw);
If you add a port, use:
$server = "192.168.1.15, 51022";
Where the IP (can be hostname to) is your server and 51022 your port.

sasql_connect(): SQLAnywhere: [-100] Database server not found

it's about more than one full day that i started sqlanywhere and i'm so interested to use it,
i worked before with sqlsrv for ms sql server and connection via php ,
but i have problem for connecting php to sqlanywhere
here is the warning message when i try to run test.php
Installation successful Using php-5.6.0_sqlanywhere.dll
Warning: sasql_connect(): SQLAnywhere: [-100] Database server not found in C:\xampp\htdocs\test.php on line 44
Connection failed
$conn = sasql_connect( "UID=DBA;PWD=sql" );
if( $conn ) {
echo "Connected successfully\n";
sasql_disconnect( $conn );
} else {
echo "Connection failed\n";
}
I'm using xampp server php 5.6 and sqlanywhere 17 developer edition.
already i downloaded the php extension and copied on ext and also added the line in php.ini (extension=php-5.6.0_sqlanywhere.dll)
demo database i ran it with cmd : dbeng17 "%SQLANYSAMP17%\demo.db".
via cmd i tried this also :
C:>dbping -d -c "uid=dba;
SQL Anywhere Server Ping U
Connected to SQL Anywhere
Ping database successful.
but when i try via php it says: Warning: sasql_connect(): SQLAnywhere: [-100] Database server not found in C:\xampp\htdocs\test.php on line 44
Connection failed
please someone tell me what is the problem ?
thank you very much.
Your PHP installation may have multiple files similar to php.ini. Make sure you are modifying the php.ini file listed in phpinfo().
- A web server such as Apache, IIS, or any web server that supports
PHP.
- PHP installed on the same computer as the web server.
- SQL Anywhere installed on the same computer as the web server.
- The client software can be used as well. SQL Anywhere PHP extension
Refrance : https://wiki.scn.sap.com/wiki/display/SQLANY/Getting+Started+with+SAP+SQL+Anywhere+and+PHP
It solved for me when I installed and used it on another system , I don't know I tried first on a system that MSSQL server was install and I couldn't run it and tried on another system that mssql server was not installed and solved :)
sorry for being late to answer and thank you very much for those who took time to help me.

PHP failed to connect to Microsoft Access Database

I am trying to connect to a Microsoft Access Database using PHP PDO, but got this error message:
SQLSTATE[IM002] SQLDriverConnect: 0 [Microsoft][ODBC Driver
Manager]Data source name not found, and no default driver specified
The error happens at this line:
$dbh = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb,*.accdb)};Dbq=C:\\wamp\\www\\phprestsql\\UTILITY.accdb");
I do not have an user name setup for the database, I also tried
$dbh = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb,*.accdb)};Dbq=C:\\wamp\\www\\phprestsql\\UTILITY.accdb;User=Admin");
and the problem still remains
What could be the problem? I checked the path for the Access Database file and it is correct.
I am using the WAMP for the PHP.
The system is Windows 7 Home Premium. Do I need to install some ODBC driver?
Edit:
I downloaded the ACE according to HansUp's suggestion, but still has the same problem.
I have also tried to convert my file to .mdb, but still has the same problem. In the PHP code I verified the ,mdb file does exist. So it must be some kind of environment issue.
Update
Forgot to mention that I was running Virtual Box on Mac. Perhaps that was the problem.
Got really frustrated, then moved on to an old Windows Vista 32 bit machine and setup the environment using all 32 bit tools. It worked in the first run.
Thanks
Ray

connect to SQL Anywhere by TCP/IP

I'm new in sql anywhere, currently I'm trying to connect using PHP.
This is what I've got so far:
$conn = sqlanywhere_connect ( "UID=usr;PWD=pass;ENG=serv;DBN=bd_name;COMMLINKS=TCPIP{HOST=10.1.1.189:2638}" );
SQL Anywhere is installed on another machine, where I can't run apache, website is running on localhost (xampp). This is only for test, when website would be ready I will connect to correct db.
This is error I've got:
Warning: sqlanywhere_connect(): The SQLAnywhere client libraries could not be loaded. Please ensure that dbcapi.dll can be found in your PATH environment variable. in C:\xampp\htdocs\core\cache\includes\elements\modsnippet\25.include.cache.php on line 21
I haven't got dbcapi.dll file, but I'm not sure I should have it.
In documentation I couldnt find this file (SQL Anywhere 10 which I've got), but for SQL Anywhere 11 I could find pages where was info about this file.
To use sqlanywhere_connect I've download SQL Anywhere module for curren ver. of PHP onto my machine and I've add it to php.ini file.
What should I do? Should I download missing file? Would it be enough or I could get more errors asking for other files?
I had a similar problem and the solution proposed here:
https://groups.google.com/forum/#!msg/sql-anywhere-web-development/zK9Tf-X3cYk/GAoqK2DnB9EJ
worked for me.
Specifically, my xampp + php needed the 32 bit dbcapi.dll but when I installed SQL Anywhere 12 I neglected to check the box to install the 32 bit version as well. Re-installing, chossing "modify" and installing the 32 bit SQL Anywhere 12 got "php test.php" working.
I would down load the missing file and go from there you are using xamp which is pre-built to talk to mySQl I doubt there is any extra .dll in the Instillation to connect with SQLAnywhere

How to connect PHP to Oracle9i server

I read some steps about this one but I can't really get it. I'm using wamp server for this with PHP 5.3.5. I tried to use the php_oci8.dll by checking the PHP>PHP extensions>php_oci8 but I get an error saying
PHP Startup: Unable to load dynamic library 'c:/wamp/bin/php/php5.3.5/ext/php_oci8.dll - The specified module could not be found
When I go to the path the php_oci8.dll is there. How can I fix this? Can anybody give me a steps on how can I configure it so that I can connect to a remote server?
Try to download the latest version of the dll here php_oci8-1.4.1-5.2-vc6-x86.zip
I already figured it out! Here's my solution:
Install Oracle XE in your PC this will give you the latest oci.dll (not php_oci8.dll)
Create a link between your user and the user you will need in connecting to your database.
Restart your PC then try running your code if it's not working copy the oci.dll of your
Oracle XE (C:\Oracle\OUIHome\bin\oci.dll) then paste it in 9i replacing the old one (make sure to have a backup). then restart your PC.
Works fine on me. Thanks for those who help me in solving this one.

Categories