Monday, 23 October 2017

Mysql database migration and special characters

So, I keep having all sorts of problems when moving my mysql database from one machine to another. The issue is that in text or varchar columns containing data that have special characters like smart quotes (those crazy curly quotes), accented letters, etc. result in scrambled data. For example the following phrase
it’s
results in
itâs
in the database and then renders incorrectly on the website as
it’s
This is supposed to be a popular problem when moving from mysql 4.0 to 4.1 or later, but I seem to have this problem moving data from one database to another on the same mysql installation. Moving from one maching with 4.1 to another with 4.1 also results in this crazy character problem.
Most of the solutions I found online end up with complicated find and replace functions to remove these problem characters. Unfortunately, that just not a solution that I'm okay with. After fiddling with it for most of the day (and giving up several times in the past), here's what I did that worked for me.

As I understand it, the problem arises from the fact that mysqldump uses utf8 for character encoding while, more often than not, mysql tables default to latin1 character encoding. (If you were smart enough to manually set the character encoding to utf8, then you'll have no problems - everyone running mysql 4.0 or early will be using latin1 since it didn't support any other encodings.) So lets say we have a database named example_db with tables that have varchar and text columns. If you have special characters that are really UTF-8 encoded characters stored in the db, it works just fine until you try to move the db to another server.
What happens when you execute the command:
mysqldump -u mysql_username -p example_db > example_db.mysql
is that mysqldump takes the latin1 encoded tables (containing utf8 characters) and translates them into utf8 encoding (so the utf8 characters are no longer what they are supposed to be) before writing it to disk. In theory, importing the data into mysql should work since it's in utf8 and mysql 4.1 and higher understands utf8, but unfortunately, the double encoding on these characters messes it up and you get funny text (as shown above). As far as I can tell when you execute:
mysql -u mysql_username -p new_db < example_db.mysql
mysql reads the data in (which is in utf8) and converts it to your character encoding. The special character that was misinterpreted by mysqldump and encoded is now decoded to the misinterpreted character and you have a funky series of symbols.
There's two ways of dealing with this that works (for me). The first is dealing with it on an individual table column level and the second works on the dump (database) level.
1. Fixing a single column
With this solution, you just perform a mysqldump as you normally would (see above) and then import as you normally would (see above). The special characters are messed up. They aren't really messed up - they just looked messed up. In actuality, your data is probably perfectly formatted in utf8 but is in a column that is latin1. So, we simply need to switch that column from latin1 to utf8 without altering the data. Unfortunately, you can't just run the ALTER TABLE command that changes the character encoding because then mysql will convert the data from latin1 to utf8 (including the special characters) and you'll end up with a different set of gibberish characters. We just need to change the type WITHOUT running a conversion. To do this change the varchar to binary and the text to blob. This change does not result in any conversion or re-encoding. Then switch it back to varchar or text with the correct encoding.
For a varchar(255) column named "column_name" in a table named "example_table":
ALTER TABLE example_table MODIFY column_name BINARY(255);
ALTER TABLE example_table MODIFY column_name VARCHAR(255) CHARACTER SET utf8;
For a text column named "text_column_name" in a table named "example_table":
ALTER TABLE example_table MODIFY text_column_name BLOB;
ALTER TABLE example_table MODIFY text_column_name TEXT CHARACTER SET utf8;
The data in that table should now be properly interpreted. If not, you've got a different problem than the one I experienced.
2. Fixing the problem on import
If you've got a lot of columns and would prefer to fix it while importing, a solution that works most of the time (repeat: most of the time) is to perform a mysqldump forcing the dump to write out data in latin1. Then on the import we "fool" mysql into thinking it's utf8 data.
For a database called example_db (one following is one line):
mysqldump -u mysql_username -p --default-character-set=latin1 example_db > example_db.mysql
Now open the dump file (example_db.mysql in this example) and edit it. There will be a line that reads like:
/*!40101 SET NAMES latin1 */;
Change latin1 to utf8:
/*!40101 SET NAMES utf8 */;
Now, import the file into mysql:
mysql -u mysql_username -p new_db < example_db.mysql
In most cases everything will import properly. In a few corner cases, the decoded data will resolve to the same text as another piece of decoded data and this could result in a conflict if this occurs on fields that must have unique entries. In this case, you'll need to re-encode manually using the first solution.
There is a popular solution online that claims you just perform a mysqldump with--default-character-set=latin1and import withmysql --default-character-set=utf8but it didn't work for me. It is possible that it might work if you deleted theSET NAMES latin1line in the dump, but if you're in there you might as well just change it to utf8.
I hope this helps some people out.
Update 2007-05-21: Even after testing the conversion so many times, sometimes it just doesn't work as expected. The last time I did this, the conversion dropped all the text after a special character. So, please test this before using.

Wednesday, 20 September 2017

Loading CSS HTLM ALA BLIZZARD

Penasaran ni liat loading website blizzard keren banget trus cari-cari deh cara buatnya akhirnya ketemu ni caranya


<html>
<head>
</head>

<style type="text/css">
.spinner-80-battlenet {
                                        width: 80px;
                                        height: 80px;
                                        background-image: url(spinner-80-battlenet-dd7ab4ec98.png);
                                        background-position: -560px 0;
                                        display: inline-block;
                                        -webkit-animation: f 8.8s steps(21) infinite;
                                        animation: f 0.8s steps(21) infinite;
}

@-webkit-keyframes f {
                                        0% {
                                        background-position: 0;
}
to {
                                        background-position: -1680px;
}
}@keyframes f {
                                        0% {
                                        background-position: 0;
}
to {
                                        background-position: -1680px;
}
}

</style>
<body>
<span class="spinner-80-battlenet"></span>
</body>

</html>
trus ini gambarnya, semoga membantu



Friday, 15 September 2017

MySQL Split String Function

Pertama buat function nya dahulu

CREATE FUNCTION SPLIT_STR(
  x VARCHAR(255),
  delim VARCHAR(12),
  pos INT
)
RETURNS VARCHAR(255)
RETURN REPLACE(SUBSTRING(SUBSTRING_INDEX(x, delim, pos),
       LENGTH(SUBSTRING_INDEX(x, delim, pos -1)) + 1),
       delim, '');
jalankan querynya

SELECT SPLIT_STR(string, delimiter, position)
contoh pemakaian

Hasil
SELECT SPLIT_STR('a|bb|ccc|dd', '|', 3) as third;

+-------+
| third |
+-------+
| ccc   |
+-------+

Thursday, 10 November 2016

Daftar nomor operator

Berikut daftar nomor awal operator seluler di Indonesia: 
Nomor awalProdukPenyedia
0811         KartuHALO                             Telkomsel
0812SimPATI, KartuHALOTelkomsel
0813SimPATI, KartuHALOTelkomsel
0814Indosat 3,5G BroadbandIndosat (IndosatM2)
0815Mentari, MatrixIndosat
0816Mentari, MatrixIndosat
0817XL Prabayar/PascabayarAxiata
0818XL Prabayar/PascabayarAxiata
0819XL Prabayar/PascabayarAxiata
0821SimPATITelkomsel
0878XL Prabayar/PascabayarAxiata
0877XL Prabayar/PascabayarAxiata
0828CeriaSampoerna Telekom
0831AxisNatrindo Telepon Seluler
0838AxisNatrindo Telepon Seluler
0852Kartu AsTelkomsel
0853Kartu As FressTelkomsel
0855Matrix AutoIndosat
0856IM3Indosat
0857IM3Indosat
0858MentariIndosat
0859XL Prabayar/PascabayarAxiata
08681ByRUPSN (Pasifik Satelit Nusantara)
0877XL PrabayarAxiata
0878XL PrabayarAxiata
0879XL PrabayarAxiata
0881SmartSmart Telecom
0882SmartSmart Telecom
0888Fren, MobiMobile-8
0889MobiMobile-8
08963Three
08973Three
08983Three
08993Three

Wednesday, 2 November 2016

Notepad++ crashed data kosong


bagi yang mengalami masalah seperti di atas ini berikut solusinya
C:\Users\user_PC\AppData\Roaming\Notepad++\backup
ato
C:\Users\user_PC\AppData\Local\Temp\N++RECOV

semoga membantu

Thursday, 18 August 2016

Responsive Filemanager image Thumbs tidak muncul


buat temen2 yang mengalami masalah penggunaan Responsive Filemanager yang tidak muncul gambar thumsnya bisa coba solusi ini

 yaitu setting di file .htaccess anda atau langsung setting di php.ini
 php_value memory_limit 50M (terserah mau kasi berapa 100M juga boleh)

Penjelasan :
menurut saya image thumbsnya tidak muncul karena pada saat melakukan convert gambar ke ukuran kecil memori yang di butuhkan terlalu kecil sehingga tidak di hasilkan gambar thumbsnya di folder thumbs. tambahan sedikit jika tidak membesarkan memory limit maka pada saat akan image_resizing (convert gambar  ke ukuran kecil) juga akan terjadi error.

contoh image_resizing  pada file config.php

'image_max_width'                         => '750',
'image_max_height'                        => '600px',
'image_max_mode'                          => 'auto',
/*
#  $option:  0 / exact = defined size;
#            1 / portrait = keep aspect set height;
#            2 / landscape = keep aspect set width;
#            3 / auto = auto;
#            4 / crop= resize and crop;
*/

//Automatic resizing //
// If you set $image_resizing to TRUE the script converts all uploaded images exactly to image_resizing_width x image_resizing_height dimension
// If you set width or height to 0 the script automatically calculates the other dimension
// Is possible that if you upload very big images the script not work to overcome this increase the php configuration of memory and time limit
'image_resizing'                          => true,
'image_resizing_width'                    => 750,
'image_resizing_height'                   => 0,
'image_resizing_mode'                     => 'auto', // same as $image_max_mode
'image_resizing_override'                 => true,
// If set to TRUE then you can specify bigger images than $image_max_width & height otherwise if image_resizing is
// bigger than $image_max_width or height then it will be converted to those values

Tuesday, 5 January 2016

operator div (%) error

operator % error jika malakukan hitungan sampai miliran
contoh : 2250000022%1000000000 maka hasil yang muncul adalah -44967274
harusnya 250000022

untuk memperbaikinya harus menggunakan function FMOD

FMOD(2250000022,100000000) maka hasilnya pasti benar


sumber :http://php.net/manual/en/function.fmod.php

Sunday, 27 December 2015

jQuery “TypeError: invalid 'in' operand a” AjaX

Contoh Koding 

$(document).ready(function() {
     $("#blog").focusout(function() {
         alert('Focus out event call');
         alert('hello');
         $.ajax({
             url: '/homes',
             method: 'POST',
             data: 'blog=' + $('#blog').val(),
             success: function(result) {
                 $.each(result, function(key, val) {
                     $("#result").append('<div><label>' + val.description + '</label></div>');
                 });
             },
             error: function() {
                 alert('failure.');
             }
         });
     });
 });
muncul error "TypeError: invalid 'in' operand a"
solusinya adalah karena data result ajax yang dihasilkan adalah string sehingga tidak terbaca oleh karena itu di butuhkan fungsi eval().
$.each(eval(result), function(key, val)
semoga membantu

Sunday, 29 November 2015

how to fix the file or directory is corrupted and unreadable

cara memperbaiki masalah yang muncul diatas dimana ketika file akan di buka atau di copy

klik on Start --> Run --> ketik cmd dan tekan Enter. 

"Command Prompt" akan muncul

Jika file kalian terletak di drive D maka ketikkan perintah berikut

chkdsk /f d: --> tekan Enter setelah itu pilih Yes

semoga berhasil


Tuesday, 6 October 2015

maximum execution time of 300 seconds exceeded in php

jika menemukan error seperti ini

tambahkan ini aja sebelum pemanggilan function

set_time_limit(600);


Monday, 14 September 2015

memory_limit di Apache

memory_limit di Apache
setting di php.ini
cari di bagian ini 
 
memory_limit = 512M
post_max_size = 80M
upload_max_filesize = 200M

trus edit berapa MB yang di butuhkan trus restart apche

Sunday, 6 September 2015

mPDF error: image cant load

mPDF error: image cant load

Jika kalian mengunaan lib mPdf dan melakukan conrvert html ke pdf namun gambar atau logo tidak muncul mungkin ini sedikit solusinya. mungkin 127.0.0.1 <> localhost jadi mesti disamakan dahulu.
caranya buka di

jalankan notepad dengan mode Administrator terus open file -> pilih All file (*.*)

mPDF error: image cant load



selanjutnya copykan lokasi file ini "C:\Windows\System32\drivers\etc " trus pilih hosts


selanjutnya pastikan tulisan yang di cetakn tebal seperti di bawah ini tanpa  "#"

# localhost name resolution is handled within DNS itself.
127.0.0.1       localhost

Friday, 4 September 2015

cara membuat underline di CSS

ini cara membuat underline yang pas dan tidak terpotong dengan text

<!DOCTYPE html>
<html>
<head>
<title>GARIS BAWAH</title>
</head>
<body>
<table style="border-collapse:collapse;font-family: arial; font-weight:bold; font-size:11px" width=100% align=center border=0 cellspacing=0 cellpadding=4>
<tr>
<td width=70% rowspan=3 align=right Valign=top>Lampiran I :</td>
                         <td  width=30% align=left>http://beatricetipz.blogspot.co.id </td>
                       
                    </tr>
                    <tr>
                         <td align=left>Nomor : </td>
                    </tr>
                 
                    <tr>
                         <td align=left style="margin-bottom:15px;border-bottom: 2px solid;display: inline-block;width: 170px; ">Tanggal :               </td>
                    </tr>

                  </table><br>
</body>
</html>

jika ingin test http://www.w3schools.com/html/tryit.asp?filename=tryhtml_default tinggal copy paste

Thursday, 3 September 2015

Function Jquery untuk left dan right


Function Jquery untuk left dan right

function Left(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else
       return String(str).substring(0,n);
    }
   
    function Right(str, n){
        if (n <= 0)
           return "";
        else if (n > String(str).length)
           return str;
        else {
           var iLen = String(str).length;
           return String(str).substring(iLen, iLen - n);
        }
    }

Catatan Jquery

jquery

untuk mengosongkan nilai comobgrid (ini berbeda dengan ini  $("#tox").combogrid("clear");)
  $("#tox").combogrid("setValue",'');

untuk enable dan disable combogrid
 $("#tox").combogrid("disable");

unutk ambil nilai combogrid
 $("#tox").combogrid("getValue")

 $("#tox").combogrid("clear");
untuk mengosongkan combogrid yang disi data dari query sql 

untuk textbox
$("#tox").attr('disabled',true);

Thursday, 27 August 2015

cara install NET framework 3.5 di Windows 8.1 ( selalu muncul window feature)

Menginstal NET framework 3.5 (include NET framework 3.0 and NET framework 2.0) di windows 8 secara offline. 

yang mengalami masalah pada saat install dotnet 3.5 muncul window feature ini solusinya
pertama siapkan dvd windows 8 atau 8.1 

buka cmd dengan user administrator (run as administrator) trus..

Wednesday, 26 August 2015

Error timezone AsiaKrasnoyarsk PHP

Jika ada yang mengamali error seperti gambar dibawah ini maka ini solusinya

error timezone AsiaKrasnoyarsk PHP

Tuesday, 25 August 2015

Install SQL Server 2008 R Error 2908

yang mengalami masalah error seperti ini 
1---->The installer has encountered an unexpected error. The error code is 2908. Could not register component {DABDC208-7DD5-4A0A-B5E9-53C857F7802D}.
2---->The installer has encountered an unexpected error. The error code is 2908. Could not register component {A72EDA2D-14E7-40C7-BAA8-25961F369C5A}.
3---->The installer has encountered an unexpected error. The error code is 2908. Could not register component {4CC7BE4F-04E1-4302-95CD-C0C29B6598B9}.
4----> An error occurred during the installation of assembly 'Microsoft.SqlServer.GridControl,fileVersion="10.50.1600.1",version="10.0.0.00000",
culture="neutral",publicKeyToken="89845DCD8080CC91",processorArchitecture="x86"'. Please refer to Help and Support for more information. HRESULT: 0x8002802F.