SQLite Fix Error – Database Disk Image Is Malformed

SQLite3 Fix Error – Database Disk Image Is Malformed

We will be using SQLite Browser, so download it here if you don’t have it.  It’s pretty easy to fix it, just follow the steps below

  1. Load up your corrupted database into SQLite Browser,
  2. Run the integrity check  under Tools > Integrity Check .The images below shows the steps and the result (error) I got
    Run Integrity Check 0
    Run Integrity Check 0
    Run Integrity Check 1
    Run Integrity Check 1

    Run Integrity Check 2 Results
    Run Integrity Check 2 Results
  3. If it returns ‘OK’, it means your database is not corrupted. If it returns anything else, you will need to fix your database. Follow through with this guide.
  4. Export your database to any format

    SQLite Browser Export
    SQLite Browser Export
  5. Import your database back to .sqlite3 (or any format you which)
    SQLite Browser Import 0
    SQLite Browser Import 0

    SQLite Browser Import 1
    SQLite Browser Import 1
  6. If you run the integrity check once more, it should return ‘OK’

If you face any other issues, let me know in the comments below and I’ll try my best to help you out

Enjoyed the content ? Share it with your friends !

PHP Quick Function For Asynchronous Multi Curl

PHP Quick Function For Asynchronous Multi Curl

If you are here, it probably means that you have a problem – you have a bunch of URLs that you need to cURL, but doing it linearly (one by one) is too slow. This is where curl_multi_init comes in. It is the asynchronous version of curl and it will help you to save lots of time (by that i mean like 80-90%)

So anyway, below is a quick function for you to use. Feel free to modify it according to your needs.

function get_content_of_urls($urls)
{
    // array of curl handles
    $multi_curl = array();
    // data to be returned
    $results = array();
    // init multi handle
    $mh = curl_multi_init();
    $i = 0;
    foreach ($urls as $url) 
    {	
        $multi_curl[$i] = curl_init();
        curl_setopt($multi_curl[$i], CURLOPT_URL,$url);	
        curl_setopt($multi_curl[$i], CURLOPT_HEADER, 0); 
        curl_setopt($multi_curl[$i], CURLOPT_RETURNTRANSFER,1);
        curl_multi_add_handle($mh, $multi_curl[$i]);
        $i++;
    }
    $index=null;
    do {
        curl_multi_exec($mh,$index);
    } while($index > 0);
    // get content and remove handles
    foreach($multi_curl as $k => $ch) {
        $results[$k] = curl_multi_getcontent($ch);
        curl_multi_remove_handle($mh, $ch);
    }
    return $results;
}

If you require any assistance, feel free to let me know in the comments below.

Enjoyed the content ? Share it with your friends !

HTML CSS Code To Put Your Element In Any Of The 9 Quadrants

HTML CSS Code To Put Your Element In Any Of The 9 Quadrants

Using the css below, you can put any element <div>, <img>, and so on in any of the 9 quadrants

  • top left, top middle, top right
  • middle left, middle, middle right
  • bottom left, bottom middle, bottom right
<style>
.topleft {
    position:absolute;
    top:0;
    left:0;
    right:0;
    bottom:0;
}
.topmiddle {
   position:absolute;
    top:0;
    left:0;
    right:0;
    bottom:0;
    margin:0 auto;
}
.topright {
   position:absolute;
    top:0;
    right:0;
    bottom:0;
    margin:0 auto;
}


.middle {
    position:absolute;
    top:0;
    left:0;
    right:0;
    bottom:0;
    margin: auto;
}
.middleleft {
    position:absolute;
    top:0;
    left:0;
    bottom:0;
    margin: auto;
}
.middleright {
    position:absolute;
    top:0;
    right:0;
    bottom:0;
    margin: auto;
}

.bottomleft {
    position:absolute;
    left:0;
    bottom:0;
    margin:0 auto;
}
.bottommiddle {
    position:absolute;
    left:0;
    right:0;
    bottom:0;
    margin:0 auto;
}
.bottomright {
    position:absolute;
    right:0;
    bottom:0;
    margin:0 auto;
}
</style>

Example :

<div class="middleright" style="max-height:450px;max-width:300px;">
    <img src="https://image.shutterstock.com/image-photo/beautiful-water-drop-on-dandelion-260nw-789676552.jpg">
</div>

 

Enjoyed the content ? Share it with your friends !

Setup PHP WordPress Dev Envrionment for Windows

Setup PHP WordPress Dev Envrionment

Requirements :

    1. Have a local php dev environment setup (MAMP/XAMPP/..)

If you have not already setup your local dev environment, you can do so by following my tutorial here

Now that you have a local php dev environment, installing WordPress is very easy.

  1. Go to the wordpress download page here and download the latest wordpress.
  2. Extract the archive to the directory of your web server. The default for XAMPP is C:\xampp\htdocs
  3. Start up Apache and MySQL
  4. Open a browser and go to http://localhost/wordpress/ and you will be greeted a page as shown below
  5. Go to your phpMyAdmin and create a database named wordpress_dev. You need not create any tables. You can refer to the images below
    xampp phpmyadmin
    xampp phpmyadmin
    xampp phpmyadmin home
    xampp phpmyadmin home
    xampp phpmyadmin create tables
    xampp phpmyadmin create tables

    xampp phpmyadmin create database
    xampp phpmyadmin create database
  6. Go back to the browser and continue with the installation, filling up the necessary details. The default username and password for MySQL in XAMPP is root and nothing/blank(there is no password)
  7. Click Continue and setup some of your other WordPress settings
  8. Your done !
Enjoyed the content ? Share it with your friends !

WordPress Code To Improve Bulk Insert Or Update Post Speed

WordPress Code To Improve Bulk Insert Or Update Post Speed

When you hit tens of thousands of posts in WordPress, the speed of wp_insert_post or wp_update_post gets significantly slower. To improve the speed, you simply add the following code and you will see that the speed improves significantly.

Add these two lines of code before your insert or update loop

wp_defer_term_counting(true); 
wp_defer_comment_counting(true);

And add these two lines after your insert or update loop

wp_defer_term_counting(false);
wp_defer_comment_counting(false);

By adding these few lines of code, you are temporarily disabling the term counts until all posts have been inserted or updated to speed up the process

Enjoyed the content ? Share it with your friends !