Create SQLite file in PHP for iOS and Android - php

I am trying to create a SQLite database file for iOS and Android. However, I am running into an issue I have, so far, not been able to solve.
Point is, I know how to create a SQLite database on both devices, and I know how to do it in PHP, but somehow they cannot read each-others databases.
How I create/open the sqlite file in php:
$dbhandle = sqlite_open('icddb.sqlite', 0777, $error);
I do queries like this:
sqlite_exec($dbhandle,$query);
When I put the filled database to iOS, this message is displayed:
file is encrypted or is not a database
How can this be solved? I have same problem when I create the SQLite file with firefox plugin 'SQLite Manager'
Note: PHP is in any case able to open the SQLite file.
Edit:
Apparently the latest stable PHP version creates a SQLite v2 file instead of a v3, which is used by all other. This probably is also my fix.

This is a SQLite version mismatch problem, Related Link:
Error: file is encrypted or is not a database

Probably they use different SQLite implementations or something similar.
Run a script that outputs the contents you want to send (for example, output the data in JSON)
Then parse the contents on the other side.

Related

General CURL and Order of operations

This is a very general question but I'm not sure the best way to go about things here.
I have two applications that want to interface. One is a Windows based app that has a database and can send CURL commands. The other is a very simple website with a MySQL database.
The main feature is that these two apps can swap database data between each other. The Windows app is currently using SQLAnywhere but could be converted to MySQL.
Anyway: On the web app there is a js function to dump all data requested into a .txt file, essentially a mysql dump. This function will be called by the Windows app via CURL. It will say
"Hey, dump the data for this table in to a txt file, then let me download it."
What I am unsure of is: Once the request to dump the data is complete, the Windows app will want the file right away. How do I say back to it, "Wait until the file is completed, and then you can download it."
I was thinking of making a dummy file and then a .txt file so the Windows app essentially gets stuck in a loop (with a timeout) until the file is renamed to .txt. Is this a good way to approach this?
Thank you.

Android local Db to XML to mySql via PHP.

I have an application with a local Sqlite database which stores records on the local phone. Now I want to increase functionality and I have come to the conclusion that I need a remote database and server based functionality to make my application more interactive. Also at this juncture I don't want my users to lose data due to this transformation. After research and lookup over the internet I came to know that I can achieve this by writing a web-service which will fetch records row by row and feed into my mySQL database. However I am confused about how to achieve this, do I convert the local databases into XML file(s) and POST them to my PHP where I parse them and feed into mySQL database or there is a better way or rather an API for this? I want a starting point, a heading. Thanks!
As you say, convert local db to XML or JSON and POST it to server. Do not forget use gzip when transfer.
You can upload the db file directly to server. Your db file locate in /data/data/app-package-name/databases. You should parse this db file in server.

How to import maxmind database using php

I know there are similar questions to this, but I never found a solution to match my case.
so my problem is i have a large file like 130MB with .txt extension.
now I want to upload this file to mysql database.
now I have problem uploading this file it gets timeout, using phpmyadmin.
is there a good way to upload this file using php?
or is there any other way besides those?
Access your server via the console (ssh, telnet, etc) and import the file using the native cli client load data syntax to import your file data:
http://dev.mysql.com/doc/refman/5.1/en/load-data.html
Edit: updating answer based on comments.
Since you can't access mysql via a CLI, i would suggest uploading the text file via ftp, then making a quick php script to import the file via a simple db connect + insert statement..
also use set_time_limit(0) to ensure the script doesn't timeout while executing the query..
You'll also need to make sure you have enough ram available to load the file.

Simples Database

I have a bunch of php pages that run on local host. Its basically a web dashboard for different web apps. I have a config.php file that has all my variables in it. They are mainly urls, password and usernames.. Now I want to remove the config file and replace it with a database. I don't want to set up an entire database though. Is there a way maybe with mysql lite that I can create a datebase file that acts like a database? So if I ever copy all the php files and move them to another computer I can just copy the database file and it will work right away. Is this possible? If yes please explain in detail how I would create, connect, and retrieve variables.
Regards
You want to use SQLite. Check some tutorials and do it how they suggest:
http://souptonuts.sourceforge.net/readme_sqlite_tutorial.html
http://zetcode.com/databases/sqlitetutorial/
http://freshmeat.net/articles/sqlite-tutorial
SQLite will do what you want: http://php.net/manual/en/book.sqlite.php.
The databases are self-contained within a single file. Check their website for more information: http://www.sqlite.org/
SQLite (nothing to do with MySql Lite Administrator) is an SQL database which stores all its data in easily transferable files.
PHP has an extension that supports SQLite.

how can I read the document using php and store database in mysql with linux?

How can I read a Word document using PHP and store it in a MySQL database on Linux?
I'm using Ubuntu and PHP5.
Here is some resources to look at
PHP upload form to send the document to the server
http://www.tizag.com/phpT/fileupload.php
PHP download, this is how you from PHP tells the browser that the response you send is to be treated as a downloadable file.
http://snipplr.com/view/205/download-file/
Here is some tips for storing data in a MySQL database
http://www.php-mysql-tutorial.com/wikis/mysql-tutorials/uploading-files-to-mysql-database.aspx
Start by checking these out and then rephrase or add some detail to your question =)

Categories