I have figured out a strange problem with using PHP SQLite3 with Windows.
I have 2 different virtuell windows server. On the first one the SQLite3 database is located and on the second one the WEB-Server and PHP.
In the same PHP script there are different functions which require access to the SQLite3 database. These is the subroutine, which is use to open the SQLite database.
class SQLite extends SQLite3 {
function __construct() {
$this->open('//COUNTRYR/CountryR_driveD/Radio/database.mldb');
}
}
The strange thing is, that the call $db1 = new SQLite() is working for one function in this script but not for another. For the second function I always get the error message Fatal error: Uncaught Exception: Unable to open database: unable to open database file in ....
It took me some time, to figure out the difference.
The function which was able to open the database was called via php xyz.php --mode='abc' --user='test' --pass='1234' and the second function was called via a browser.
So the difference can only be different access rights in both cases.
For the PHP call of the function, the 'IUSR' has access rights for the database.
Due to the fact, that the server with the database is no Web server, I can not enable 'IIS_IUSRS' access rights for the database and I also don't want to give 'IIS_IUSRS' access rights to the database for security reasons.
Is there any other way to solve this problem?
Is 'IIS_IUSRS' the user which requires access for the WEB browser?
Related
I wanna create a sqlite3 database in PHP but I get an error from PHP
Error
Fatal error: Uncaught Exception: Unable to open database: unable to open database file
Codes
$database = new SQLite3('myDatabase.db');
Note: My PHP version is 7.1
Note: My database name is not duplicate and sqlite3 must make it
Thanks for attention
Your code is correct and should create the database file if it doesn't exist.
Most probably it's a user right issue, check the permissions of the folder where you are trying to create the file in.
Check the directory permissions. The folder containing the SQLite file must be writable by the appropriate user.
Using Ajax integrated chat with PHPBB3. It is supposed to use the mysql connections that the site uses. The database tables have been created. When accessing, I continue to get the error
'>[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/di/container_builder.php on line 291: file_put_contents([ROOT]/chat/../cache/container_[ROOT]/chatslashdotdotslash.php): failed to open stream: Invalid argument Error-Report: No connection could be made because the target machine actively refused it. Error-Code: 2002'
Edit: I have not had any trouble connecting to the database with the web application itself. I've read that the hosts file may need to be edited. I made sure that the socket server option for AJAX chat is set to false. I'm not sure what this error is actually trying to say here or what the actual connection error is. Can someone point me in the right direction?
The php class container_builder is where the error falls. Here is the function being called at that point:
protected function dump_container($container_filename)
{
$dumper = new PhpDumper($this->container);
$cached_container_dump = $dumper->dump(array(
'class' => 'phpbb_cache_container',
'base_class' => 'Symfony\\Component\\DependencyInjection\\ContainerBuilder',
));
file_put_contents($container_filename, $cached_container_dump);
I cleared out the particular cache file, which was then recreated, but the error does not go away. I would think there is no problem with connectivity to the database by the application. Cache is stored on the server not the database.
I am trying to use PHP's COM interface to query a database and create pivot tables from the data in an Excel Workbook.
I have configured the DCOM settings on the local machine to grant the user Local Access, Local Launch, and Local Activation privileges as well as Full Control of Configuration Permissions. I have also tried all three Identity settings.
Here is the code I am using:
<?php
$application = new COM("Excel.Application") or die("Unable to load Excel.");
$workbook = $application->Workbooks;
$workbook = $workbook->Add();
$sheet = $workbook->Worksheets(1);
$sheet->Activate();
$application->Quit();
?>
This is the error I am getting:
PHP Fatal error: Uncaught exception 'com_exception' with message 'Unable to lookup `Workbooks': Access is denied.
This is different than error I was getting before which told me that I didn't have access to the Excel COM object. Setting the permissions fixed that.
Environment is:
Windows Server 2012 R2
Excel 2010 (64-bit)
PHP 5.5.9 (64-bit)
I never was able to solve this, so we had to come up with a different solution and it actually is more stable and performs better. Hope it helps anyone else that may run into the same issue.
Our database is MySQL (but this should be possible with most databases), so we moved our query into its own script and used the mysql client to write the results directly to a file.
We then created an excel template with a data connection to the file and used the connection as the data source for the pivot tables.
Lastly we wrote a short vbscript to open the template, refresh the pivot tables, then and save the file as a new copy.
This had the added benefit of allowing us to make stylistic changes using Excel's interface, which was much faster than doing it programmatically.
I moved the installation to a different server. I updated the configfile in the var/ directory and the banners are served, but the admin interface is not working.
i get the error:
A fatal error occurred OpenX can't connect to the database. Because of
this it isn't possible to use the administrator interface
i cleaned the cache directory in var but then i get
PHP Fatal error: Call to undefined method MDB2_Error::quoteIdentifier() in /[path]/opx/lib/OA/Upgrade/VersionController.php on line 50
I dont know which version this is, but it looks like its at least 2 years old.
Is there any special cache in place im not aware of?
Any help on this would be much appreciated.
Mental note,.. if you have the db on a different server then openx it does not matter if you set the host to the ip of the db server and the port.. as long if you not set protocol=protocol !!!
this is by far the most stupidest thing i have ever seen, there is no need for a protocol config, as php always uses the socket if you set "localhost".
It's not easy to tell exactly what's wrong here, but one can make a good guess:
As we can see from the error message, there is an object in your code that doesn't implement the method quoteIdentifier().
There are mainly two possible reasons for this: Either we're calling an older or newer version of the same Class instance which doesn't implement the method. Maybe because it's deprecated or who knows. Or the object simply isn't of the expected type.
Lo and behold, if we look for an MDB2 related class that DOES implement this method, it's the class MDB2. Not MDB2_Error! So now we know the reason for the error, it's time to speculate about the root cause.
Connecting to a database with MDB2 works roughly like this:
$mdb2 =& MDB2::connect('pgsql://usr:pw#localhost/dbnam');
if (PEAR::isError($mdb2)) {
die($mdb2->getMessage());
}
There it is. We can see that $mdb2 can actually be of type MDB2_Error, in case connecting goes wrong for some reason. So that is the cause: Your code cannot connect to the DB for some reason. So the next obvious step should be checking if your db user has the correct rights and is using the correct password. I am 100% sure your admin backend doesn't use the right credentials.
I create a simple class from a different file and include it
to a page that used to create an object of that class.
Everything works fine, the problems occurs is when I update
the class, I need to manually access the class from my browser
then the page that I create the object will get the latest modified class
or it will receive Error.
below is the page code I use to create an object of the class
<?php
function __autoload($class_name) {
require '/classes/'.$class_name . '.php';
}
$rain = new myClass;
echo $rain->TestMethod(12345,123451);
?>
If I update my class, and without accessing it manually from my browser I will receive this error from my Apache2.
PHP Fatal error: require(): Failed opening required '/classes/myClass.php' (include_path='.:/usr/share/php:/usr/share/pear')
Check if you are using a PHP op cache, or any Apache PHP cache or something that makes your php files not been readead from disk when you change them.
I usually have many problems with shared servers because these modules.
(i see the / is the root folder. It's a common mistake if your classes are not in the root folder of your webserver.)