Latest Post

Error: No input file specified.

While trying to run a codeigniter app the other day I came across this error just after I had finished uploading the files and making the ne...

Tuesday, June 20, 2017

SQLITE How to work with multiple databases at the same time

Let us suppose you have 3 (or however many) databases that you want to work with in sqlite e.g. say you have a Dev, Test and a Production database which you want to transfer data between them.
  1. Open a sqlite command prompt
  2. Open to to the databases you want to work with using the .open command as well as the attach command
    1. sqlite> .open /path/to/Dev.db
    2. sqlite> attach '/path/to/Test.db' as test
    3. sqlite> attach '/path/to/Productiom.db' as prod 
  3. Verify the opened databases using .databases command to confirm that you have all 3 databases opened 

  4. Now you can run sql statements against tables in any of the databases e.g.
    1. For tables in Dev.db you can do a direct select * from tbl2 or insert into tbl2 etc
    2. For table in the Test.db you will need to prefix the table name with the alias specifiedwhen you attached the Test.db i.e. test and likewise for Production.db tables you will need to prefix the tables with prod
      e.g. insert into test.tbl2 select * from prod.tbl2 to copy
      data from Production.db table into a Test.db table

Saturday, February 27, 2016

Error: No input file specified.

While trying to run a codeigniter app the other day I came across this error just after I had finished uploading the files and making the necessary config edits for the environment in which i copied the app to.

"No input file specified"

A quick google search lead me to a stackoverflow post that suggested having a look at my htaccess and making the following edit (add a ? after the index.php):

.htaccess before

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L] 

.htaccess after making the edit ( adding ? after the index.php )

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php?/$0 [PT,L] 

Saturday, January 2, 2016

HOWTO: Determining Your Current MySQL Version

To determine the version and release of your currently installed MySQL installation, there are a number of options:

1) Using a command client (mysql), the server version of the MySQL server to which you are connected is shown once you are connected

For example, here is the output from a MySQL Community Server edition installed on Linux:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.0.27-standard MySQL Community Edition - Standard (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.


2) You may also determine the version information using the version variables, version and version_comment.
mysql> SHOW VARIABLES LIKE "%version%";
| Variable_name           | Value                                    |
| protocol_version        | 10                                       |
| version                 | 5.0.27-standard                          |
| version_comment         | MySQL Community Edition - Standard (GPL) |
| version_compile_machine | i686                                     |
| version_compile_os      | pc-linux-gnu                             |
5 rows in set (0.04 sec)
3) You can also use the STATUS command which displays the version as well as version comment information. For example

mysql> STATUS;
./client/mysql  Ver 14.12 Distrib 5.0.29, for pc-linux-gnu (i686) using readline 5.0

Connection id:          8
Current database:
Current user:           mc@localhost
SSL:                    Not in use
Current pager:          /usr/bin/less
Using outfile:          ''
Using delimiter:        ;
Server version:         5.0.27-standard MySQL Community Edition - Standard (GPL)
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    latin1
Db     characterset:    latin1
Client characterset:    latin1
Conn.  characterset:    latin1
UNIX socket:            /tmp/mysql.sock
Uptime:                 1 day 3 hours 58 min 43 sec

Threads: 2  Questions: 17  Slow queries: 0  Opens: 11  Flush tables: 1  Open tables: 6  Queries per second avg: 0.000

Hope this helps someone

Tuesday, May 26, 2015

error: The following untracked working tree files would be overwritten by merge

I'm using Git for version control and because the repository is sometimes directly modified for urgent fix to test some theory in the staging server (not the best way for doing things), I’ll occasionally get an error similar to the one below one when doing a git pull:

error: The following untracked working tree files would be overwritten by merge
 [list of file(s) here]
Please move or remove them before you can merge.
In my case, I will want to overwrite these files. So I use the following:
git fetch --all
git reset --hard origin/master

This will get the latest repository files without merging and resets the master branch and overwrites the modified ones.

Wednesday, February 4, 2015

Google Maps API HOWTO: Retain zoom and center after refresh using cookies

Q: How do I make Google Maps retain the user's view (zoom level and center point) after an HTTP refresh?

A: You could do the following:

// Use events to load the saved map state any given time

// You could use event listeners to keep track of map view changes as zoom change, map finishes loading tile etc
google.maps.event.addListener(map, 'tilesloaded', tilesLoaded);
function tilesLoaded() {
    google.maps.event.clearListeners(map, 'tilesloaded');
    google.maps.event.addListener(map, 'zoom_changed', saveMapState);
    google.maps.event.addListener(map, 'dragend', saveMapState);

// Here are the suppoert functions needed to make all this work

function saveMapState() { 
    var mapZoom=map.getZoom(); 
    var mapCentre=map.getCenter(); 
    var mapLng=mapCentre.lng(); 
    var cookiestring=mapLat+"_"+mapLng+"_"+mapZoom; 
    setCookie("myMapCookie",cookiestring, 30); 

function loadMapState() { 
    var gotCookieString=getCookie("myMapCookie"); 
    var splitStr = gotCookieString.split("_");
    var savedMapLat = parseFloat(splitStr[0]);
    var savedMapLng = parseFloat(splitStr[1]);
    var savedMapZoom = parseFloat(splitStr[2]);
    if ((!isNaN(savedMapLat)) && (!isNaN(savedMapLng)) && (!isNaN(savedMapZoom))) {
        map.setCenter(new google.maps.LatLng(savedMapLat,savedMapLng));

function setCookie(c_name,value,exdays) {
    var exdate=new Date();
    exdate.setDate(exdate.getDate() + exdays);
    var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
    document.cookie=c_name + "=" + c_value;

function getCookie(c_name) {
    var i,x,y,ARRcookies=document.cookie.split(";");
    for (i=0;i
Source: Stackoverflow
NOTE: If you are using Google API v2 then you just can use map.savePosition()to save the current position of the map and then map.returnToSavedPosition()to restore the saved position . Trying to use these functions in v3 of the API can result in an error "map.savePosition is not a function" or something to that effect.

Chitika Ads