July 24, 2008 by Alex Polski | No Comments »

Backing up MySQL tables under extremal conditions

I guess every web developer has ever had a situation when he needed to get the dump of MySQL table but standard tools like phpMyAdmin or mysqldump were unavailable, but you had an ability to run PHP script. Some days ago I had similar situation and now I want to share this solution with you.

First of all, let’s get the table structure. It’s more simpler.

$sql = "show create table test_table";
$res = mysql_query($sql);
$data = mysql_fetch_assoc($res);
echo $data['Create Table'];

This PHP script prints SQL string for ‘test_table’ table creation.

And now let’s get the table data.

$sql = "select * from test_table";
$res = mysql_query($sql);
while ($row = mysql_fetch_assoc($res)) {
  $fields = array();
  $values = array();
  foreach ($row as $key => $value) {
    array_push($fields, addslashes($key));
    array_push($values, '\'' . addslashes($value) . '\'');
  }
  $fields = implode(', ', $fields);
  $values = implode(', ', $values);
  echo "insert into test_table ($fields) values ($values);\n";
}

Note, if the table contains a lot of data, you will need to call set_time_limit(0) function.

Share and Enjoy:
  • del.icio.us
  • Digg
  • Reddit
  • Ma.gnolia
  • Technorati
  • Propeller
  • Facebook
  • StumbleUpon
  • Furl
  • blogmarks
  • Google
  • E-mail this story to a friend!


July 14, 2008 by Alex Polski | No Comments »

Add Perl and PHP search engine plugins to your browser

Recently I’ve started to read one interesting book: “Spidering hacks” by Kevin Hemenway and Tara Calishain. I think this book is a MUST READ for every spider developer.

All examples in this book are written in Perl. But I’ve just started to learn Perl and I look for the description of one or another Perl function in manual very often. It’s very comfortable to use search engine plugins in Firefox for these purposes.

Firefox search engine plugins

But I was wondered very much when I did not find any firefox search engine plugin for Perl manual. So I decided to make my own one. I’ve quickly found good article which helped me to do it.

Install Perl manual search engine plugin (Firefox2+, IE7)

Install PHP manual search engine plugin (Firefox2+, IE7)

Install CPAN search engine plugin (Firefox2+, IE7)

Share and Enjoy:
  • del.icio.us
  • Digg
  • Reddit
  • Ma.gnolia
  • Technorati
  • Propeller
  • Facebook
  • StumbleUpon
  • Furl
  • blogmarks
  • Google
  • E-mail this story to a friend!


July 11, 2008 by Alex Polski | 1 Comment »

Image Drop Shadow plugin for wordpress

Yesterday I found a great article about adding a drop shadow to images by Brian Williams and decided to implement this method on my blog. After that I though if my readers want to have the stylish drop shadows on their blogs too and decided to develop a wordpress plugin which will automatically add a drop shadow to each posted image.

Wanna to have the image drop shadows on your blog like on my one? ;-)

Just download the plugin, install it, activate it and enjoy!

Download Image Drop Shadow wordpress plugin now (zip, 4.4 kb)

Share and Enjoy:
  • del.icio.us
  • Digg
  • Reddit
  • Ma.gnolia
  • Technorati
  • Propeller
  • Facebook
  • StumbleUpon
  • Furl
  • blogmarks
  • Google
  • E-mail this story to a friend!


July 10, 2008 by Alex Polski | No Comments »

All in One SEO Pack + runPHP = short meta descriptions

If you use wordpress plugin like runPHP and All in One SEO Pack plugin, you can have a problem. This thing can take place if you insert php tags at the beginning of the post. In this case All in One SEO Pack will truncate the text of the autogenerated meta description tag.

For example, if the beginning of your post is

My <a href="<?php echo get_permalink(15); ?>">previous post</a> was about wordpress.

the autogenerated meta description will not be “My previous post was about wordpress” as you expect, but it will be “My”. This is because of strip_tags php function does not support php tags inside html tags.

To fix this issue just insert the row:

$text = preg_replace('/<\?php.+?\?>/i', '', $text);

in the beginning of the functions trim_excerpt_without_filters and trim_excerpt_without_filters_full_length.

Share and Enjoy:
  • del.icio.us
  • Digg
  • Reddit
  • Ma.gnolia
  • Technorati
  • Propeller
  • Facebook
  • StumbleUpon
  • Furl
  • blogmarks
  • Google
  • E-mail this story to a friend!

July 9, 2008 by Alex Polski | 1 Comment »

50 films to see before you die

Do you remember I was going to develop my iGoogle gadget? Yeah, I did it! :)

The idea of a gadget was taken from the famous “50 films to see before you die” list by Film4. This is a list of the 50 best movies which Film4 recommend everybody to see. My gadget shows the information about each film from this list like film’s title, year, plot, thumbnail, links to the film’s trailer, IMDB page and Amazon page and has handy navigation bar which allows to move from one film from the list to another, mark the film as seen, move through unseen movies.

Here is the preview:

To add this gadget to your iGoogle page just click on this button: Add to Google

P.S.: BTW, I’ve already seen 12 films and keep seeing the others. The list is really great!

Share and Enjoy:
  • del.icio.us
  • Digg
  • Reddit
  • Ma.gnolia
  • Technorati
  • Propeller
  • Facebook
  • StumbleUpon
  • Furl
  • blogmarks
  • Google
  • E-mail this story to a friend!


« Older Entries