Friday, 25 August 2017

PHP script to export table creation SQL from MySQL Database structure


The script itself is fairly self explanatory.
Note that the table name is enclosed with backticks; this prevents SQL errors if the table is named with a reserved word, which happened to me when I was writing the script.

<?php
 
set_time_limit(0);

$username = 'XXXXXX';
$password = 'YYYYYY';
$hostname = 'ZZZZZZ';
$database = 'AAAAAA';

try {
 $pdo = new PDO("mysql:host={$hostname};dbname={$database}", $username, $password);
}
catch(PDOException $e) {
 die("Could not connect to the database\n");
}

echo '<pre>';
$stmt1 = $pdo->query('SHOW TABLES', PDO::FETCH_NUM);
foreach($stmt1->fetchAll() as $row) {
 $stmt2 = $pdo->query("SHOW CREATE TABLE `$row[0]`", PDO::FETCH_ASSOC);
 $table = $stmt2->fetch();
 echo "{$table['Create Table']};\n\n";
}
echo '</pre>';
 
?> 

Wednesday, 23 August 2017

Reset PrestaShop admin password through the MySQL

Reset your PrestaShop password through the MySQL database using the phpmyadmin tool in cPanel.

1. Login to phpmyadmin and select the Prestashop database for which you want to change admin password.

If you don’t know which database then check configuration file is placed in this config folder under the name of settings.inc.php. Open it and get the database name from there (you may find it in the _DB_NAME_ field).

You also need to copy-paste the _COOKIE_KEY_ from this page(settings.inc.php). You will need it later for the password resetting:





2) Find the ps_employee table and click on it: Now you see the users list. Choose the user you need and press Edit: 


3)
In the passwd line choose MD5 from the drop-down menu. Copy-paste the _COOKIE_KEY_ from your settings.inc.php file into the Value field.

Once the key is copy-pasted, please scroll to the end of the line and enter your password right after the key, without the space after the key. Press Go:






That's it!



Thursday, 10 August 2017

Google remarketing tag - iframe height issue

I've noticed that Google's remarketing code inserts an iframe at the bottom of my page. The problem is that the iframe messes up my layout (it's 13px high and leaves a blank white vertical space at the bottom)


 For solution in my sites i use following css code and it worked

iframe[name='google_conversion_frame'] { 
    height: 0 !important;
    width: 0 !important; 
    line-height: 0 !important; 
    font-size: 0 !important;
    margin-top: -13px;
    float: left;
}

Wednesday, 2 August 2017

How to trigger the window resize event in JavaScript?

Seems to work with Chrome, FF, Safari, but not: IE !

 window.dispatchEvent(new Event('resize'));

.
.
.
That didnt work on all devices for me. I had to trigger the event like this:

var evt = document.createEvent('UIEvents');
evt.initUIEvent('resize', true, false, window, 0);
window.dispatchEvent(evt);