PHP connect to MS Access database - Provider not found - php

I know there are tons of questions about this on SO. But I've been trying to fix this since a month with no luck.
At work we have this very old website that uses an access database, and I cannot do anything about it.I want to work on some changes on my local PC using wamp server. So I donwloaded the website along with the db. Here is how it's supposed to connect :
$conn = new COM('ADODB.Connection');
$db = realpath("dbalerts.mdb");
$conn->Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=$db");
But it's giving me this error:
Fatal error: Uncaught exception 'com_exception' with message 'Source: ADODB.Connection
Description:Provider cannot be found. It may not be properly installed.'
in C:\wamp\www\testaccess\index.php:5 Stack trace: #0 C:\wamp\www\testaccess\index.php(5): com->Open('Provider=Micros...') #1 {main} thrown in C:\wamp\www\testaccess\index.php on line 5
It's a test folder whith an index.php where only that code is written. In the same folder is dbalerts.mdb
I tried everything I know. I downloaded AccessDatabaseEngine.exe from MS website which is supposed to have the driver. And it installed properly with no errors( had to uninstall office because it was 64bit)
I am on a win8 machine
Any ideas how I can fix this all while still using COM and ADODB? Because I can't go through changing the connections of every .php file in that website (it's old and poorly designed so not adaptable to changes)

Related

using cpanel database after copy it to local machine

I am trying to shadow a live website to my local machine, I have finished all the copy thing for home folder and database from cpanel.
So far, I didn't make any change on code part, and just installed xampp and set up phpmyadmin.
after I set the localhost, and loaded the local page then below message displayed.
Fatal error: Uncaught Error: Call to undefined function
mysql_connect() in F:\htdocs\ramtaps\includes\php_library.inc:41 Stack
trace: #0 F:\htdocs\ramtaps\includes\php_library.inc(19):
phpLibrary->createGlobalDatabaseConnection() #1
F:\htdocs\ramtaps\includes\php_library.inc(469):
phpLibrary->__construct() #2
F:\htdocs\ramtaps\includes\config\master.php(859):
include('F:\\htdocs\\ramta...') #3 F:\htdocs\ramtaps\index.php(4):
include('F:\\htdocs\\ramta...') #4 {main} thrown in
F:\htdocs\ramtaps\includes\php_library.inc on line 41
So I looked into the code and it said that mysql_connect is deprecated.
I am pretty new one this field and tried few things and they didn't work so far.
If anyone advises me regarding on this, I would really appreciate.
although you did not mention your PHP version, it is obvious that you are using PHP with version > 7
mysql_connect was removed in PHP 7.0.0 and above
http://php.net/manual/en/migration70.incompatible.php
either install older version of PHP, or change your code
and maybe this is usefull for you http://php.net/manual/en/mysqlinfo.api.choosing.php

connecting PHP to MSSQL error

I'm currently trying to connect to a MSSQL database, but from what i've read so far, there are actually extensions and files that i need to download from microsoft itself which i've went and download it here.
https://www.microsoft.com/en-us/download/details.aspx?id=20098
The error that i'm receiving currently receiving is the following.
Fatal error: Uncaught Error: Call to undefined function sqlsrv_connect() in C:\xampp\htdocs\index.php:5 Stack trace: #0 {main} thrown in C:\xampp\htdocs\index.php on line 5
As far as i understand, i know that i'm supposed to append some extensions into the php.ini located in my xampp\php\php.ini file. However, even after appending the file from microsoft, i still can't seem to get connected.
I heard some people mentioned that the php version that i'm using which is currently PHP Version 7.1.1 has some issues connecting back to MSSQL databases but i'm not entirely sure.
Would someone be able to point me to right direction? i've tried looking up and down appending different files into the extension but i still can't seem to do it.
Thank you very much in advance.
edit:
PHP 7 on IIS: Call_user_function could not be located
i've also visited this link, however i'm unsure whether if this is related to the issue I have as i'm on 7.1

Cassandra PDO connection PHP

I've got Cassandra working nicely on Debian server however I'm hoping to connect to it from a PHP application.
Currently it seems PDO it the way to go for anything complex as I'm able to use CQL. I'm using the latest forked version of the Apache Cassandra-PDO project.
I'm using the latest Cassandra 2.03 and I can connect to it fine from CQLSH in the terminal.
When I try and connect in PHP using the following code
$db_handle = new PDO("cassandra:host=localhost;port=9160");
I get the following error
Fatal error: Uncaught exception 'PDOException' with message 'CQLSTATE[08006] [8] TTransportException: Transport not open' in /var/www/index.php:9 Stack trace: #0 /var/www/index.php(9): PDO->__construct('cassandra:host=...') #1 {main} thrown in /var/www/index.php on line 9
I've seem a few issues alike on the internet, but no solutions as yet. Hopefully someone can provide some insight into the issue here.
Error 8006 is connection failure. I think you need login and password in PDO Statment like this:
$pdo = new PDO('mysql:host=localhost;dbname=products', 'root', 'root');
Try running 'nodetool status' from the cli to verify the IP address the server is running on.
Then perhaps change localhost to 127.0.0.1 if instead the local host.

error import excel to mssql. "Fatal error: Uncaught exception 'com_exception' with message"

i'm working on a project which is allowing a user to upload an excel file, and when the user click submit, the data from the excel file will get into MSSQL database. for now, the upload is working, but it couldn't get into the MSSQL database.
i've used the same script before and it worked fine (Windows XP). now that i've changed my machine to Windows 7, i get that COM error. i've tried almost everything that i could get online (the dcomcnfg configuration), but none is helping.
pls help.
below are the error message:
<pre>
Application name: Microsoft Excel
Loaded version: 14.0
function import-->open below filename:
C:/xampp/htdocs/www/mysystem/tmp/import_excel_0.32887000 1336015991.xls
Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> Microsoft Excel<br/><b>Description:</b> Microsoft Excel cannot access the file 'C://xampp/htdocs/www/mysystem/tmp/import_excel_0.32887000 1336015991.xls'. There are several possible reasons:
• The file name or path does not exist.
• The file is being used by another program.
• The workbook you are trying to save has the same name as a currently open workbook.' in C:\xampp\htdocs\www\mysystem\import\ImportData.php:52
Stack trace:
#0 C:\xampp\htdocs\www\mysystem\import\ImportData.php(52): variant->Open('C:/xampp/htdocs...')
#1 C:\xampp\htdocs\www\mysystem\import\ImportData.php(19): Import('C:/xampp/htdocs...')
#2 C:\xampp\htdocs\www\mysystem\index.php(698): require('C:\xampp\htdocs...')
#3 {main}
thrown in C:\xampp\htdocs\www\mysystem\import\ImportData.php on line 52
Ok this solved it for me
if you’ve got IIS configured try this:
Run “dcomcnfg” to get to Component Services
Open Component Services > Computers > My Computer > DCOM Config
Search for Microsoft Excel Application or the appropriate application you working with on COM
Right-Click on it and open the properties
Choose “Identity” tab
Normally this is set to “the launching user” by default. You have to change this to “the interactive user”.
Apply these new settings and test your COM application. It should work fine now.
http://www.php.net/manual/en/class.com.php

MongoCursorException 'couldn't get response header'

I am developing a website using PHP and mongodb. I access the mongodb with PECL-mongo, and have run into an annoyance. Every now and then, I get an error like this (I've anonymized the paths)
Fatal error: Uncaught exception 'MongoCursorException' with message 'couldn't get response header' in
/PATH/index.php:38 Stack trace: #0
/PATH/index.php(38): MongoCursor->rewind() #1
/PATH/template.inc(29): get_sidebar() #2
/PATH/index.php(13):
require_once('PATH/...') #3 {main} thrown in PATH/index.php on line 38
According to the documentation, this means:
The driver could not fetch a reply header from the database, so it
gave up. Check if the database is still up and the network is
connected and try the query again.
But I know that the database is up because I am doing this locally on my own machine over loopback. No connection is made to the outside world.
Simply trying again often works. Is this a possibly a bug in PHP's driver for mongo? Could this be a "miscompile" issue (I compiled from source, but with very benign flags, -march=native -O2)?
Has anyone seen this before?
Searching around, I only see references to some stupid facebook game having the same error.
EDIT: I just downgraded my PECL driver to version 1.1.4 and so far, the problem seems have gone away. So this may simply be a bug in the 1.2.x series. If anyone can shed any light on it, that would be great.
EDIT: I am not doing anything complex here, the code that is having the issue litterally looks like this:
$m = new Mongo();
$collection = $m->my_db->collection;
$results = $collection->find(array("favorite"=>true))->limit(5);
i solved this problem with get new version mogodb.dll
you can see http://www.mongodb.org/display/DOCS/PHP+Language+Center

Categories