Scrap

June 26th, 2007

Hmmmm…
The previous piece of code is a scrap if you have to deal with MySql4 server with all-defaults.
So… I continued my challenge – I want my data back (and workin’) ;)
Stay tuned for next round…

P.S. For MySql5 all works great…

Popularity: 15% [?]

UTF-8 fix – when charset is set to Latin1

June 23rd, 2007

Situation: you have MySQL 5 database with tables which claimed to have Latin1 charset. You filled the base (with MySQL Front, PhpMyAdmin or any other tool) with info. There IS non alnum chars (like TM, (c), long –, ellipsis etc.)

Now you want it back, and your pages are utf-8 encoded, but when you queries the base, ??’ sign returned instead of your cute symbols. Shit.

Never mind, if you can see those chars with PhpMyAdmin – I’ll help you to convert them to use them.

First, mysql5 seems to be utf-8 lover (even if other charset is claimed). So – it’s simple. Just exec SET NAMES utf8 right after database initialisation.

Second, query all the data you need into array.

Third, just do utf8_encode on data with your loved scrap

Forth, exec SET NAMES latin1

Fifth – write your data back

Sixth – tell your application to use utf8_decode when reading and utf8_encode when writing those data.

That’s all – now you can easilly transfer your data to MySQL4* or MySQL5 servers – and your app will work there!

Example:

// init skipped 
 
/*********************************** 
 * Database connect 
 **********************************/ 
$o_db = new myDB(DB::connect(DB_DSN)); 
$o_db->db_setFetchMode(DB_FETCHMODE_ASSOC); 
$o_db->db_query('SET NAMES utf8'); 
 
$q = 'SELECT page_id, page_head_title, page_head_description, page_head_keywords 
  FROM '.DB_PREFIX.'pages 
'; 
foreach ($page as $k => $p) 
  foreach (array('page_head_title', 'page_head_description', 'page_head_keywords') as $field) 
    $page[$k][$field] = utf8_encode($p[$field]); 
$o_db->db_query('SET NAMES latin1'); 
 
foreach ($page as $p) 
{ 
  $up = 'UPDATE '.DB_PREFIX.'pages 
    SET 
    page_head_title = '.$o_db->db_quote($p['page_head_title']).', 
    page_head_description = '.$o_db->db_quote($p['page_head_description']).', 
    page_head_keywords = '.$o_db->db_quote($p['page_head_keywords']).', 
    WHERE page_id = '.$o_db->db_quote($p['page_id']).' 
  '; 
  $o_db->db_query($up); 
}

*see next post

Popularity: 13% [?]

WordPress 2.2.1

June 22nd, 2007

Oops, WordPress 2.2.1 is out, and I’m still not ready!

Ok, I upgraded all the blogs with my plugs, and let’s see what happens.

Popularity: 2% [?]

Car-crash accident

June 22nd, 2007

Yesterday I had an car-crash accident. I was in a bus, I stayed and played Solitaire on my phone. The bus crashed into another vehicle, then into the shop. Brain shaking did not happen, because i haven’t one

Car crash accident

And I’m happy – I’m alive

And this chinese guy is much lucky and happier than I

Popularity: 2% [?]

Developers versus clients

June 4th, 2007

Why always they think that coding – it’s an instant process?

Just another little quote:

We were under the understanding that coding would have been complete and we were to have seen your work late last week

Yeah, right. Do you mean next week?

Popularity: 10% [?]

Very positive video – It’s hard to be god

May 31st, 2007

I just don’t want to comment it – just watch!

Popularity: 9% [?]

PHP 4 and XML

May 31st, 2007

What a mess.

Php 4 had no human usable XML handling implementation.
And almost all libraries it’s a mess…

I found one good article about it, but it’s in russian.
OK, I’ll try to translate it later (maybe only examples  )

And as for me – I found what i wanted. Small and effective library.

Here it is under more tag

Read the rest of this entry »

Popularity: 10% [?]

New WordPress

May 20th, 2007

Hi again.
WordPress 2.2 Getz is pretty cool ;)
Except one little thing.
Widgets.
They’re now in the core.
And (as always) one little annoying error in release code.
This bug prevents Otto’s ExecPHP from working. Another plugins that allows to run PHP code gone wild too.
No, actually they working, until you want 2 or more blocks…
Solution is CVS. You need to upload fixed version of widgets.php into your wp-includes folder.
You can take it .zipped – here.

Oh, and I think my plugs needs some widgetization too ;)

Popularity: 2% [?]

Hey, they banned!

April 27th, 2007

Youtube banned else one video from my post
I don’t know why but I had strange experience.
It took a hour to realize that video is banned, not youthumb plugin malfunction… Thanks god, it’s over ;)

P.S. Hmmmm. Why they banned that video?

Popularity: 10% [?]

WordPress 2 updated

April 25th, 2007

Do not forget to update your blogs to WordPress 2.1.3 and 2.0.10.
Recommended ;)

Popularity: 1% [?]

Feed ShowZ plugin update

April 25th, 2007

Feed ShowZ plugin updated to 0.92 version.
Added: Autocensor, Bottom link code.
Some bugs fixed.
Code re-arranged.

Available here: Feed ShowZ plugin homepage

Popularity: 14% [?]

Quit smoking!

April 3rd, 2007

Hey guys!

Quit smoking as I do!

Dennis Leary was right – there is no cure for cancer, think of it.

=)

Popularity: 1% [?]


Switch to our mobile site