I am trying to make use of sqlite for the first time, now I have used this :
$this->linkIdentifier = new SQLiteDatabase($database);
and it created a database just fine as website.sqlite opening it again doesn't give any problem but as soon as I use http://code.google.com/p/phpliteadmin/ to create a table and I try to open it again it gives me this error : file is encrypted or is not a database
What could be causing this ?
Just for clarification: There are SQLite database-files of version 2 and version 3. With "new SQLiteDatabase()", you create a db-file of version 2. With "new SQLite3()" you create a file of version 3.
PhpLiteAdmin has support for both versions if the appropriate php extension is installed. PhpLiteAdmin tells you the extension being used when you open the "structure" tab of the database under "SQLite extension". It should say "SQLiteDatabase" there if you open a version 2 database. If it does not, e.g. because this extension is not installed, you might not be able to edit a version 2 database in phpLiteAdmin.
The SQLiteDatabase extension might not be included in recent versions of PHP, e.g. in PHP 5.4, it is only available via PECL.
I suggest to use PHP's own SQLite3 functions to create and save a database. Make sure to set the SQLITE3_OPEN_CREATE flag.
Related
I installed the MongoDB PHP driver on Windows 10 (I'm using WAMP equipped with PHP 5.6.25. following the istructions I found at http://php.net/manual/en/mongodb.installation.windows.php and I installed also the libbson and libmongoc libraries (requested as requirements) as written at http://php.net/manual/en/mongodb.requirements.php.
Then, I added the bin folders of MongoDB, libbson and libmongoc to system path.
However, even if I can see the php_mongodb extension in the extensions list of WAMP, launching phpinfo() the mongo extension doesn't appear with the others.
Furthermore, tryng to connect to my database with
<?php
$mongo=new MongoClient("");
$db=$mongo->galileo;
$collection= $db->items;
print_r("Number of documens: "); ?>
I got the error
Fatal error: Class 'MongoClient' not found in C:\wamp64\www\galileo\index.php >on line 21
At a first look, reading this error, it might seem like that PHP is looking for php_mongodb extension in the uncorrect folder i.e. C:\wamp64\www\galileo\index.php (where the index page of my project is placed) instead of the correct one C:\wamp64\bin\php\php5.6.25\ext where all the extensions are.
But, looking at php log file php_error.log I find also a warning that says:
PHP Warning: PHP Startup: Unable to load dynamic library 'c:/wamp64/bin/php/php5.6.25/ext/php_mongodb.dll' - Il sistema operativo non pu� eseguire %1.
in Unknown on line 0.
(for not Italian speaking, the phrase after - means the operating system can't execute %1, even if I can't imagine what %1 stands for).
Even using the new class MongoDB\Driver\Manager I get the error
Fatal error: Class 'MongoDB\Driver\Manager' not found in C:\wamp64\www\galileo\index.php on line 21
and the same warning.
Do you notice some error or forgetfulness in the installation process as I described and, if not, do you know how to fix the problem?
The problem is certainly related to WAMP and I think is related to the multiple php.ini in his folders. In fact, in the apache folder you can find a php.ini file that cannot be modified, otherwise nothing works at all; at the same time any changes made to the php.ini file in the php folder seems have no effect except making appear the mongodb extension in the extensions list.
So, I try using XAMPP, as suggested in this video tutorial and it works. Using Composer I was able to install also the PHP library and not only the driver.
you should not use 'MongoClient class' anymore, this extension that defines this class is deprecated. look at here.
instead, you should use MongoDB\Driver\Manager class. please read http://php.net/manual/en/class.mongodb-driver-manager.php.
and the setup must be like this in php:
$mongo = new MongoDB\Driver\Manager("mongodb://localhost:27017");
And if you still use the old class; you either need to install the old legacy extension (pecl install mongo) and use PHP 5.x, or update your code to use this new driver's classes as the old driver is not available for PHP 7. There is an upgrade guide at here.
the last part is from derickr's answer in this issue on github: https://github.com/mongodb/mongo-php-driver/issues/300
I have a database file on my computer called testing.sqlite, which contains a copy of me database that I want to use for testing (rather than connecting to my ordinary MySQL production server).
I created an entry in the config/database file in laravel as instructed, setting it to access the sqlite file, and it all look right. But when I try and actually do anything, I get the error message:
[Illuminate\Database\QueryException]
SQLSTATE[HY000]: General error: 26 file is encrypted or is not a database (SQL: select * from sqlite_master where type = 'table' and name = vendor_alerts)
I can access the file using sqlite testing.sqlite from the command line, why can't laravel read it?
The problem is that the version of sqlite is different. Laravel uses sqlite3, wheareas the sqlite command on your console might be an earlier version. Run sqlite -version from the command line to check your version - is is probably 2 something. You need to install sqlite3, and you'll find that it is not compatible - i.e. sqlite3 testing.sqlite will produce the same error you are getting from laravel.
So, upgrade your command line sqlite version, and copy the data into a new sqlite3 database, and laravel will work without trouble.
It seems nobody had this problem yet.... With db2_connect I found docs that decrible how to load a default library list (*LIBL) on connection but with PDO nothing!
I'd like to perform statements without specifing always the library name in front of file name. I already created a JOB DESCRIPTION to load the libraries, and when I log in with the PC5250 emulator those library are online.
But if I run a query with PDO without specifying the library name following is returned:
Error executing sth in testGet for AS400 SQLSTATE[42S02]:
Base table or view not found: 0
[IBM][System i Access ODBC Driver][DB2 for i5/OS]SQL0204 -
TESTFILE in WEB type *FILE not found.
(SQLPrepare[0] at ext\pdo_odbc\odbc_driver.c:206)
To use the library list, you will need to make sure your connection attributes specify system naming, and I would avoid setting a current schema.
Without much knowledge of PHP + PDO, the stackoveflow tag wiki gives a good introduction. Check that PDO is configured for proper settings for DB2 for i, not LUW or z. Likewise check db2_connect settings. (Why are you using that, instead of straight ODBC?)
I know it's been awhile since you posted but I came across some info on how to do library lists using the PDO driver... see http://yips.idevcloud.com/wiki/index.php/XMLSERVICE/PHPPDOChangeLog.
So for example you could do something like this:
$options = [
PDO::ATTR_PERSISTENT => true,
PDO::ATTR_AUTOCOMMIT => true,
PDO::I5_ATTR_DBC_SYS_NAMING => true,
PDO::I5_ATTR_DBC_LIBL => "LIB1 LIB2 LIB3",
];
$db = new PDO("ibm:SYSTEM", "user", "password", $options);
Keep in mind this will probably require a recent Zend Server (since Dec 2014). I know the latest stuff is in the new ZS 8.5 but I'm not sure about older releases.
You might also be able to leave off the library list option - in my limited testing this appears to let it use the library list from the job description. I'm not sure about the current library and YMMV but I'd be curious to hear back if it works for you or not.
Also for what it's worth an email address for the official maintainer is listed on http://pecl.php.net/package/PDO_IBM. Questions could also be sent to the WEB400 mailing list (http://lists.midrange.com/mailman/listinfo/web400), I think people who are involved in the development of the pdo_ibm driver are on there as well.
If you're talking about these docs, then that is if you're using PDO_IBM on IBM i. I don't think those settings are supported on any other platform. From your error message, it seems that you are using the IBM i Access ODBC driver through PDO_ODBC. The IBM i Access ODBC driver connects to a QZDASOINIT prestart job running in QUSRSYS subsystem. If you want those jobs to use a different job description, you need to use CHGPJE to change it: CHGPJE SBSD(QUSRSYS) PGM(QSYS/QZDASOINIT) JOBD(MYLIB/MYJOBD). If you're using SSL connections, also change QZDASSINIT jobs. You'll need to end any existing QZDASOINIT/QZDASSINIT jobs and the new pre-start jobs will pick up the new settings. Note that this will affect all ODBC, JDBC, OLEDB, .NET connections for IBM i Access drivers.
You can configure the library list through the DSN as well, by setting the DBQ connection string or DefaultLibraries ODBC.INI setting or setting the "Library List" value under the Server tab from the DSN configuration GUI on Windows.
I'm using an IDE "Phpstorm" with "wampserver". i want to connect with MySQL data source, but i'm getting a problem:
Connection to MySQL - DatabaseName#localhost failed: Exception in thread "main" java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at com.intellij.persistence.database.console.RemoteJdbcServer.main(RemoteJdbcServer.java:15)
I also downloaded mysql-connector-java-gpl-5.1.29.msi and installed it, but I'm still getting some problems.
When I had this issue, there was a section of the Data Sources and Drivers Dialogue box that said "Driver Files" I expanded it and there was a link to download driver files.
I clicked it - and after a few seconds (with no obvious visual progress indicator) the message changed to say using MySQL drivers.
After that it worked.
Short version:
Open the Database tab, usually located on the very upper right of
PHPSTORM.
Click on the small wrench (Data Source and Property)
In this new popup window choose MySQL from the left.
Delete Red driver files with the minus symbol
Click Download
From there on you should be good to go. (phpstorm handles the rest)
Detailed version:
Open the Database tab, usually located on the very upper right of PHPSTORM.
Click on the small wrench (Data Source and Property)
New Version v2020:
If it's not there open it from
View -> Tool Windows -> Database
New Version v2020
- In this new popup window choose MySQL from the left.
New Version v2020:
- Now you should be on the settings tab where you can see driver
files, if any of them are red just delete them with the
minus symbol, as soon as there are no driver files left you are able to click on download.
If any of the above fail try these:
Delete the drivers in use and reinstall. Usually located at ~/.PhpStormXXXX/config/jdbc-drivers.
After that repeat the first instructions in this post. (short version)
Using a proxy?
Make sure you have configured it within phpstorm!
At Appearance & Behavior -> System Settings -> HTTP Proxy.
Make sure you have the latest drivers:
Create a new mysql datasource, if the driver needs an update it will display it on the very bottom of the popup
try other versions
New Version v2020:
Installing the Driver Manually
I couldn't find any official Jetbrains mysql driver repo page, but these urls are official and work:
http://download.jetbrains.com/idea/jdbc-drivers/mysql-connector-java-5.1.35-bin.jar
http://download.jetbrains.com/idea/jdbc-drivers/mysql-connector-java-5.1.40-bin.jar
http://download.jetbrains.com/idea/jdbc-drivers/mysql-connector-java-5.1.44-bin.jar
http://download.jetbrains.com/idea/jdbc-drivers/mysql-connector-java-5.1.45-bin.jar
http://download.jetbrains.com/idea/jdbc-drivers/mysql-connector-java-5.1.46-bin.jar
http://download.jetbrains.com/idea/jdbc-drivers/mysql-connector-java-5.1.47-bin.jar
http://download.jetbrains.com/idea/jdbc-drivers/mysql-connector-java-5.1.48-bin.jar
The Newest version number can be found here:
https://dev.mysql.com/downloads/connector/j/5.1.html
just replace the [VERSION] with the current version e.g.
http://download.jetbrains.com/idea/jdbc-drivers/mysql-connector-java-[VERSION]-bin.jar
Add the downloaded file with clicking on the small grey plus. (in older versions green and on the right)
New Version v2020:
Or try the official mysql repo (caution you MUST register to download!):
Go to http://dev.mysql.com/downloads/connector/ within the dropdown select "Platform Independent" it will show you the options to download tar or zip files.
Download one of them and extract it,
Within the resulting folder you will find a mysql-connector-XXX.jar file.
Add it to phpstorm in the mysql datasource dialog box.
Other stuff:
Useful phpstorm UI reference link
Code Monkey's answer pointed me in the right direction, but my firewall blocked the download from within PHPstorm. Luckily the error message included the download URL to find the driver.
So I downloaded the driver with help from the URL, and then added it manually:
PHPStorm 2020.1 with Material Dark theme:
Hit Alt+0 or View→Tool Windows→Database to open the Database tool window.
Click the pancakes-with-wrench icon
Click the TEST CONNECTION button
This will prompt you to download the drivers - do it
You will have to enter your root password again
Had the same issue. I resolved it in the Data source and drivers window on panel Mysql. There is checkbox "Use provided driver" and next to it there was link "Version 5.1 (latest)". I clicked on it a now it works.
Anyone else who came here trying to locate the Database tab in the latest version of PhpStorm (Version 2017.1), which is hidden at first, try the following, taken from PhpStorm Website
Database support is provided through the Database Tool Window on the right-hand side of the IDE. Use the View | Tool Windows | Database menu or Find Action, by pressing Ctrl+Alt+A (Alt-CMD-A on Mac OS X) and search for "Database" to open it.
if nothig of above works, you can delete .PhpStorm2017.3/config/jdbc-drivers folder. then navigate to your db properties and download the driver again
I'm trying to use the informix pdo driver but I always get the following error:
"could not find driver"
I'm using the Microsoft IIS with PHPManager and PHP version 5.3.5. The php_pdo_informix.dll is located in the correct folder and enabled in the php.ini
Are there any ideas where the problem lies?
I don't use PHP nor pdo drivers, but you can use Process Monitor by SysInternals/Microsoft to see if php_pdo_informix.dll is loaded.
Often Informix drivers do not load, because some environment variables are not set. Especially INFORMIX_DIR, CLIENT_LOCALE, DB_LOCALE, SERVER_LOCALE, DBLANG. Do you have Informix Client installed? Are you able to set up and test ODBC connection?
You can also add directory with php_pdo_informix.dll to PATH.
EDIT:
I downloaded php_pdo_informix.dll and it seems that this file is broken. I tested it with my Python utility to check dll libraries: http://code.activestate.com/recipes/576522-searching-dll-and-exe-files-in-path/
c:\download>which_dll.py php_pdo_informix.dll
2011-03-04 08:03:45 32833 [b] c:\download\php_pdo_informix.dll
ver:5.2.5.5
trying to load "php_pdo_informix.dll" ...
Cannot load "php_pdo_informix.dll" !!!
And MessageBox appeared (translation from Polish)
---------------------------
python.exe - Bad image file
---------------------------
Aplication or libarary DLL c:\download\php_pdo_informix.dll is not correct image of Windowns NT. Check it with install disc.
---------------------------
OK
---------------------------
SHA1 sum of library I downloaded:
b38bc54839c7c4b82e2057763ef1c6584dcbbb1f *php_pdo_informix.dll
If your PHP is VC9, try this:
php_pdo_informix_PHP5.3_VC9.zip
I had this problem, and I solved by installing the CSDK from IBM to get the php_pdo_informix.dll to work, you can download it from http://www14.software.ibm.com/webapp/download/search.jsp?rs=ifxdl