Archive

Author Archive

Mysql db commands

May 5th, 2012 peter Comments off

Dump ALL MySQL Databases

mysqldump –user=XXXXXXXX –password=XXXXXXX -A > /PATH/TO/DUMPFILE.SQL

Dump Individual or Multiple MySQL Databases

mysqldump –user=XXXXXXXX –password=XXXXXXX –databases DB_NAME1 DB_NAME2 DB_NAME3 > /PATH/TO/DUMPFILE.SQL

Dump only certain tables from a MySQL Database

mysqldump –user=XXXXXXXX –password=XXXXXXXX –databases DB_NAME –tables TABLE_NAME > /PATH/TO/DUMPFILE.SQL

make dumps compatible with the old MySQL version, add the following switch:

–compatible=mysql323

Put Myqsl database back

mysql –verbose –user=XXXXXXXX –password=XXXXXXXX DB_NAME < /PATH/TO/DUMPFILE.SQL

Categories: web development Tags:

PHP 5.1 date(): getdate(): and assorted Time Zone errors

January 31st, 2011 peter No comments

Ok So you have your Apache server WIth PHP installed and you keep getting this error on your sites

date(): It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘UTC’ for ‘GMT/0.0/no DST’ instead

OR

getdate(): It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘UTC’ for ‘GMT/0.0/no DST’ instead

It turns out your shiny new server set up has changed if your using PHP 5.1 or greater you now need to tell php what time zone to use.

Rather than editing all your sites / scripts just update your .htaccess with

php_value date.timezone Europe/London

You can also set the default time zone in your php.ini file if you have access / the script should revert to UTC or GMt as it used to be but you will get the E_warning as above.

replacing Europe/London with the appropriate time zone for your server see full list: http://www.php.net/manual/en/timezones.php

Categories: Latest, web development Tags: , ,

How to order posts by number of Facebook Likes

November 10th, 2010 peter No comments

I was recently asked to produce a facebook “like” page where by the website owner could add entries and visitors could like those entries via facebook. The entries could then be displayed in order of most likes. see http://purplepanda.eu/like/

Afetr a brief discussion the cient told me they have used wordpress before and where comfortable using it, so hey lets build the site for wordpress.

First off we need somewhere to store our number of facebook likes against the post so add the following to functions.php

function add_custom_field_automatically($post_ID) {
   global $wpdb;
   if(!wp_is_post_revision($post_ID)) {
      add_post_meta($post_ID, '_my_key', '0', true);
   }
}
add_action('publish_page', 'add_custom_field_automatically');
add_action('publish_post', 'add_custom_field_automatically');

This will automatically add a custom field called _my_key to any new posts with a default value of “0″ the reason for the _ before my_key is to hide the custom field from the post editor.

Next you’ll need to add the facebook like button to your code no use adding the button from facebook.com you have to write your own add this code where you want the button to appear inside the Post loop:

<div class="fb_like_div">
  <iframe src="http://www.facebook.com/widgets/like.php?href=<?php the_permalink(); ?>&amp;layout=button_count&amp;show_faces=false&amp;width=95&amp;action=like&amp;font&amp;colorscheme=light&amp;height=20&amp;locale=en_US" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:95px; height:24px;" allowTransparency="true"></iframe>
  </div>

Next we need to check how many likes we have against each post and update the custom field we created at the beginning “_my_key”.
This code is for Satndard Permalinks e.g p?=123.
For nice permalinks use the code underneath!
You can add this to your header.php file:

global $wp_query;
$Magic_no = $wp_query->post->ID;

$data = file_get_contents('http://graph.facebook.com/?id='.bloginfo('url').'?p='. $Magic_no);

$json = $data;

$obj = json_decode($json);
$like_no = $obj->{'shares'};
$meta_values = get_post_meta($Magic_no, '_my_key', true);
//$meta_values = 1;
//if ($like_no == '2') {
   echo $meta_values;
if ($like_no == $meta_values) {
   
} else if (empty($meta_values)) {
   add_post_meta($Magic_no, '_my_key', $like_no, true);
   update_post_meta($Magic_no, '_my_key', $like_no, false);
   
} else {
   update_post_meta($Magic_no, '_my_key', $like_no, false);
   
}

Code for nice permalinks:

global $wp_query;
$Magic_no = get_permalink();
$Magic_no_postid = $wp_query->post->ID;
//echo get_permalink();
$data = file_get_contents('http://graph.facebook.com/?id='. $Magic_no);

$json = $data;

$obj = json_decode($json);
$like_no = $obj->{'shares'};
$meta_values = get_post_meta($Magic_no_postid, '_my_key', true);
//$meta_values = 1;
//if ($like_no == '2') {
//   echo "Number of Likes".$meta_values;
if ($like_no == $meta_values) {
   
} else if (empty($meta_values)) {
   add_post_meta($Magic_no_postid , '_my_key', $like_no, true);
   update_post_meta($Magic_no_postid , '_my_key', $like_no, false);
   
} else {
   update_post_meta($Magic_no_postid, '_my_key', $like_no, false);
   
}

Now to display the posts Create a new page template and add this betwee the get_header and get_posts:

<?php
$featuredPosts1 = new WP_Query();
$featuredPosts1->query('cat=1&posts_per_page=20&meta_key=_my_key&orderby=meta_value&order=desc&paged='.$paged);
while ($featuredPosts1->have_posts()) : $featuredPosts1->the_post(); ?>
<div id="list_wrapp_inner">
  <a href="<?php the_permalink(); ?>">
  <div id="list_wrapp_1_storycontent">
<?php the_content(); ?>
  </div>
</a>
  <div class="fb_like_div">
  <iframe src="http://www.facebook.com/widgets/like.php?href=<?php the_permalink(); ?>&amp;layout=button_count&amp;show_faces=false&amp;width=95&amp;action=like&amp;font&amp;colorscheme=light&amp;height=20&amp;locale=en_US" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:95px; height:24px;" allowTransparency="true"></iframe>
  </div>
  <div class="fixed"></div>
</div>    
  <?php endwhile; ?>
Categories: Wordpress, web development Tags:

Seo >Start Here<

October 23rd, 2010 peter No comments

Introduction to SEO

When SEO started, SEO wasn’t called SEO. It was best described by those who practiced it as a form of hacking.

The early search engines weren’t the best , so it was relatively easy to figure out their sorting algorithms. There was a time when Infoseek’s algorithm was almost entirely based on keyword density and keyword position.

I’m sure many  SEOs remember those days with a sense of nostalgia. It was more of a pure technical pursuit back then.

As search engines got more sophisticated, and more money flowed online, the nature of the game changed. SEO moved beyond technical hacking to an exercise in making connections.

In Googles early days, you could build a couple of high PR (Page Rank) Links and that was enough to get you ranking top ten. (Click here is you want to read the current status on PR) Add a few more if you really wanted to go hard.  It’s clear to see we haven’t completely left the era of High PR but it’s clear to see their has been a shift away from this method.

Today a holistic approach is required to capitalize on SEO.

Get your head round current SEO

If you’re starting out in SEO now, Don’t try and cover it all at once it’s going to take a while.

It helps to understand the big picture first. The reason people engage in SEO is about making money, Driving visitors to your site, Building your online presence, and increasing your search ranking.

They want people to connect with them, rather than their competitors.

They want people to find their web site.

They want people to do this so they can convert these people to buyers, of their goods, their services, or their ideas. If a site were only to rank, on keyword terms no-one searched for, or that weren’t directly applicable to the objectives of the business, then the SEO work is largely useless.

So SEO isn’t solely about rankings.

The rankings must translate to something tangible. In most cases, this means gaining qualified visitor traffic.

A low bounce Rate

To get this traffic, a site must do more than rank, a site must appeal to visitors. To appeal to visitors, the SEO must first understand them.

Once the SEO provider understands what is available to the visitor and what the aim is of the Employer of the SEO provider, relevant traffic can be driven to he relevant sections of a site.

If for instance we are providing SEO for a company that sells Crockery there’s no point providing quality seo for plates and the visitor arriving at the home page and then having to find that information within the site. We want to send the visitor straight to the most relevant part of the site relating to Plates.

Please share your thoughts and ask some questions in the comments as I’m looking to keep this post updated and added to.

Categories: seo Tags:

iOS 4.1 and 4.2

October 22nd, 2010 peter No comments

iOS 4.1 is available for download from apple so get your iPhones, iPods, and iPads updated.

iOS 4.2 is available as of November 2010 I’ll be writing about that soon also.

As well as the usual bug fixes iOS 4.1 also has some brand new features!

A new Camera App

A new button that turns on HDR mode.

Take great photos that capture a wider range of light intensity using the new high dynamic range (HDR) setting on iPhone 4, which automatically combines multiple exposures into a single HDR image.

The restriction on uploading High Def video directly from the iPhone has been removed.

Upload HD video to YouTube and MobileMe from your iPhone 4.

The addition of game center.

iOS 4 introduces the Game Center app. An out-of-the-box social gaming network for iPhone 4 and iPod touch.1 Invite friends to join. Then totally crush them. Take a look at how your score ranks among your friends and other players of each game. Compare game achievements with your friends. Get matched up and put together a select group of friends to play. Or choose to automatically go up against people you don’t know in a multiplayer game. Read More here >>

Face Time.

FaceTime is just another way iOS 4 seamlessly integrates hardware and software to make every iPhone feature as easy to use as it is groundbreaking. Now when you wish your friends could be there, they actually can be. With just a few taps, you can see your friends and family while you talk to them — iPhone 4 to iPhone 4 or new iPod touch over Wi-Fi.

Watch a cut down Keynote here:

If you have a spare two hours watch it in full:

http://www.apple.com/apple-events/wwdc-2010/

Categories: web development Tags: , , , ,

It’s here Or maybe not Html5

October 21st, 2010 peter No comments

So Html5 isn’t due for release untill 2022 but sites like facebook are already using it?

Html5 is till being developed by the web Hypertext Application technology working group, and developemnt is still currently at “Working Draft – Last Call” the second of five total recommendation levels.

The basics are safari, Chrome, Firefox and no Internet Explorer (version 9) are using Html 5 on an increasing level and these technologies are being adopted by an increasing number of sites so we could argue Html 5 is here already albeit in Beta.

What can I do with Html5 that I couldn’t do before with Html 4 and some plugins?

Thats just it you don’t need the plugins,

But if the plugins are available why not just use them?

As plug ins are not set by an independent body as an industry standard they will not necessarily be available on all platforms, and in the case of Flash and Divx they can be very hardware intensive regularly causing crashes on lower spec machines.

So what is available with Html5 and where can I see some examples?

The biggest changes are media markup tags such as <audio>, <video>, and <canvas>.

We can see the audio tag in use here: Note you’ll want to get a html5 browser such as safari or chrome, opened to enjoy these examples.

http://www.apple.com/html5/showcase/audio/

http://www.jezra.net/projects/pageplayer

The video tag has been adopted by Youtube, BBC iPlayer, and vimeo.

http://www.apple.com/html5/showcase/video/

The canvas tag is at work, with gmail, and scribd.

So you lke wat you hear?

Here’s some of the best examples on the web currently of html5.

http://www.apple.com/html5/

http://studio.html5rocks.com/

This site is using it all <canvas>, <audio>, and <video>

http://thewildernessdowntown.com/

I like what I see how do I learn how?

http://dev.w3.org/html5/spec/

http://www.html5rocks.com/

Here are the latest tutorials from Html 5 Rocks .com


RSS Content

Categories: Latest, web development Tags:

Am I really doing that well? Exclude Internal Traffic

October 19th, 2010 peter No comments

Are you actually getting 100 hits per day already or is that you reading and reviewing your own webiste?

Your most likely to be the most frequent visitor to your website and or people from your own intranet (that pretty much means anybody on your wifi, or Ethernet network).

This is especially true if you are running a blog site / cms site or an e commerce site that means you have to visit your site regularly to update the content.

Here is how to ad a custom filter in Google Analytics to remove the home grown traffic.

Start by going to Filters in your Google Analytics and click Add Filters. Up pops the normal filter form.

Following the example below, placing your own IP address into the field, add it to what ever profile you want. Now all internal traffic is gone.

If you don’t know your i.p address click here.

Of Course you could filter out by City, or State or even Country (if you lived in Luxembourg) However some genuine traffic will come from as close to home as next door, If you are using Mobile broadband or dial up or maybe don’t have a fixed i.p you can filter by i.p starting with and use the first two to three numbers in my example I would filter by all i.p’s starting “92″

Server Technology

October 8th, 2010 peter No comments

I’ve often found cause to complain at the slow uptake of the latest serevr technologies when working on different projects.

I take it all back…

9 hours into re-compiling Apache and php on Mac os X server.

Categories: Latest Tags:

Incoming!

September 26th, 2010 peter No comments

Don’t believe a word you hear about incoming links, the quality of the link or anything to do with link exchange because the truth is; it doesn’t really matter how many links you have to your site and what sites link to you.

What does matter is the way the sites link to you and how often new links show up to your site.

If you wake up tomorrow and, overnight, 1 million other sites decided to link to you, that would not affect your position in any way (what it may do is hurt your listing because it will look like spam).

Here is how links work for you:

  1. If you are a boat builder and another boat builder site links to you, that will give you a boost because you are being linked to a site that has some relevance to yours.
  2. If your site sells traditional jukeboxes and the link to your site is like this traditional jukeboxes that will give you a boost because the link is a search term.
  3. If you acquire new links slowly over the course of time, that will give you a boost because it looks like your site is gaining popularity.
  4. If people link to internal pages of your site, as well as your home page, that will give you a boost because it looks like you have lots of pages of relevant information.
Categories: seo Tags: , ,

Fresh

September 20th, 2010 peter No comments

No I’m not talking 80′s street.

You may be able to get your site listed in the top ten within 30 - 60 days, but that’s no guarantee it will stay there.

As per my previous example of pizzajim they were at Number one because we put them there but as the updates are few and far between (mostly new menus) the site has started to become a bit stale.

If your site is not continually being updated with fresh content and growing, then the search engines will simply dump it

in favor of newer fresher sites.  You should be adding a new page to your site every time the crawler visits and updating your old content as much as you can.  Daily is preferred, but weekly at the very least.  This will mean that the crawler will have fresh content to index and new links to explore.  Thus, it will never see your site as stale and drop it.

Categories: seo Tags: