<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
<channel>
<title>Chris Hope's LAMP Blog</title>
<link>http://www.electrictoolbox.com</link>
<description>Chris Hope's blog for Linux, Apache, MySQL and PHP, otherwise known as LAMP.</description>
<lastBuildDate>Sat, 04 Jul 2009 18:23:21 GMT</lastBuildDate>
<pubDate>Sat, 04 Jul 2009 18:23:21 GMT</pubDate>
<copyright>http://www.electrictoolbox.com</copyright>

<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/ElectricToolboxBlog" type="application/rss+xml" /><feedburner:emailServiceId>ElectricToolboxBlog</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
<title>Count the words in an FCKeditor instance with Javascript</title>
<link>http://feedproxy.google.com/~r/ElectricToolboxBlog/~3/n6v0ndnygi8/</link>
<guid isPermaLink="false">http://www.electrictoolbox.com/count-words-fckeditor-javascript/</guid>
<pubDate>Sat, 04 Jul 2009 17:00:00 GMT</pubDate>
<description><![CDATA[<p>A couple of days ago I looked at how to count the words in a textarea or input with jQuery and in this post look at how to do the same but for an FCKeditor instance. FCKeditor is an in-browser HTML editor. The code for counting the words uses regular Javascript and does not require jQuery.</p>]]></description>
<content:encoded><![CDATA[
<p>A couple of days ago I looked at how to <a href="http://www.electrictoolbox.com/jquery-count-words-textarea-input/">count the words in a textarea or input with jQuery</a> and in this post look at how to do the same but for an FCKeditor instance. FCKeditor is an in-browser HTML editor. The code for counting the words uses regular Javascript and does not require jQuery.</p>
<h2>Example</h2>
<p>First of all here's an example to show you it working. If you are reading this in an RSS reader you will need to <a href="http://www.electrictoolbox.com/count-words-fckeditor-javascript/">click through</a> to view this in a web browser for it to work.</p>
<script type="text/javascript">
function FCKeditor_OnComplete(editorInstance) {
	
	fckeditor_word_count(editorInstance);
    editorInstance.Events.AttachEvent('OnSelectionChange', fckeditor_word_count);
    
}

function fckeditor_word_count(editorInstance) {

	var matches = editorInstance.GetData().replace(/<[^<|>]+?>|&nbsp;/gi,' ').match(/\b/g);
	var count = 0;
	if(matches) {
		count = matches.length/2;
	}

	document.getElementById('example_word_count').innerHTML = count + " word" + (count == 1 ? "" : "s") + " approx";

}
</script> <script type="text/javascript" src="/examples/fckeditor/fckeditor.js"></script>
<div id="example_word_count">&nbsp;</div>
<script type="text/javascript">
var oFCKeditor = new FCKeditor('FCKeditor1');
oFCKeditor.ToolbarSet = "Basic";
oFCKeditor.BasePath = "/examples/fckeditor/";
oFCKeditor.Height = "100";
oFCKeditor.Create();
</script>
<p>Type some text into the above FCKEditor instance and the word count above it will change as you type.</p>
<h2>The HTML</h2>
<p>The only HTML required is the container for the word count:</p>
<pre style="border: 1px #666 solid; padding: 10px; padding-bottom: 1em; overflow: hidden; overflow-x: auto; background: #eeeeee; font-size: 105%;">
&lt;div id=&quot;word_count&quot;&gt;&lt;/div&gt;
</pre>
<h2>The Javascript code</h2>
<p>Here's the Javascript to make the word count functionality work:</p>
<pre style="border: 1px #666 solid; padding: 10px; padding-bottom: 1em; overflow: hidden; overflow-x: auto; background: #eeeeee; font-size: 105%;">
function FCKeditor_OnComplete(editorInstance) {
   
    fckeditor_word_count(editorInstance);
    editorInstance.Events.AttachEvent('OnSelectionChange', fckeditor_word_count);
   
}

function fckeditor_word_count(editorInstance) {

    var matches = editorInstance.GetData().replace(/&lt;[^&lt;|&gt;]+?&gt;|&amp;nbsp;/gi,' ').match(/\b/g);
    var count = 0;
    if(matches) {
        count = matches.length/2;
    }

    document.getElementById('word_count').innerHTML = count + &quot; word&quot; + (count == 1 ? &quot;&quot; : &quot;s&quot;) + &quot; approx&quot;;

}
</pre>
<p>FCKeditor_OnComplete() is triggered by the FCKEditor itself when it's finished loading. The function defined above calls my fckeditor_word_count function to initialise the word count container with the current number of words and then attaches an event to the editor instance so whenever the selection is changed it calls the word count function again.</p>
<p>The word count function gets the HTML from the FCKEditor instance, strips out the HTML tags and non-breaking spaces and then matches word boundaries (this is covered in <a href="http://www.electrictoolbox.com/jquery-count-words-textarea-input/">my previous post about word counting</a>).</p>
<p>Finally, the word_count container is updated with e.g. &quot;0 words approx&quot;, &quot;1 word approx&quot;, &quot;2 words approx&quot; etc.</p>
<h2>Browsers tested</h2>
<p>I have tested the above code in IE6, IE8, FF1, FF3.5, Chrome 2. It worked in all of them testing with 9000 words generated from <a href="http://lipsum.com/">lipsum.com</a>.</p>
<p>On my speedy machine with lots of RAM with the newer browsers there was really no difference between having the word counting on and off with 9000 words; on a virtual machine with 256MB on the older browsers it got fairly sluggish with 9000 words when word counting so it will pay to be careful enabling a function like this if you are editing large documents on older computers, because of the regular expressions being run on every keypress.</p>
<p>Note that as per the <a href="http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/JavaScript_API">FCKeditor documentation</a> &quot;in IE, this event [OnSelectionChange] does not fire on every keystroke, but only on some random keystrokes.&quot;</p><div style="margin-top:10px; border-top:1px solid #ccc;">
<h2>Related posts:</h2>
<ul>
<li><a href='http://www.electrictoolbox.com/jquery-count-words-textarea-input/'>Count the words in a textarea or input with jQuery</a> (Friday, July 3rd 2009)</li>
<li><a href='http://www.electrictoolbox.com/get-selected-html-from-fckeditor-instance/'>Get the selected HTML from an FCKEditor instance</a> (Friday, April 17th 2009)</li>
<li><a href='http://www.electrictoolbox.com/get-selected-text-from-fckeditor-instance/'>Get the selected text from an FCKEditor instance</a> (Tuesday, April 7th 2009)</li>
<li><a href='http://www.electrictoolbox.com/get-html-from-fckeditor-instance/'>Get the HTML from an FCKEditor instance</a> (Sunday, March 29th 2009)</li>
<li><a href='http://www.electrictoolbox.com/getting-handle-fckeditor-instance/'>Getting a handle to an FCKEditor Editor Instance</a> (Tuesday, March 17th 2009)</li>
<li><a href='http://www.electrictoolbox.com/insert-html-fckeditor/'>Insert HTML into FCKEditor</a> (Friday, February 13th 2009)</li>
</ul>
</div>

<p><a href="http://feedads.g.doubleclick.net/~a/D5-drOUyDgPrn4g_NQV4Sjs0Qgo/0/da"><img src="http://feedads.g.doubleclick.net/~a/D5-drOUyDgPrn4g_NQV4Sjs0Qgo/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/D5-drOUyDgPrn4g_NQV4Sjs0Qgo/1/da"><img src="http://feedads.g.doubleclick.net/~a/D5-drOUyDgPrn4g_NQV4Sjs0Qgo/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ElectricToolboxBlog/~4/n6v0ndnygi8" height="1" width="1"/>]]></content:encoded>
<feedburner:origLink>http://www.electrictoolbox.com/count-words-fckeditor-javascript/</feedburner:origLink></item>
<item>
<title>Disable textarea resizing for Safari and Chrome</title>
<link>http://feedproxy.google.com/~r/ElectricToolboxBlog/~3/A6MQsvOH8y0/</link>
<guid isPermaLink="false">http://www.electrictoolbox.com/disable-textarea-resizing-safari-chrome/</guid>
<pubDate>Fri, 03 Jul 2009 17:00:00 GMT</pubDate>
<description><![CDATA[<p>The wbekit based browsers Safari and Google Chrome allow the HTML textarea to be resized by default with a grab handle in the bottom right corner. There may be times when you want to disable this function so a textarea cannot be resized.</p>]]></description>
<content:encoded><![CDATA[
<p>The wbekit based browsers Safari and Google Chrome allow the HTML textarea to be resized by default with a grab handle in the bottom right corner. There may be times when you want to disable this function so a textarea cannot be resized.</p>
<h2>Screenshot example of resize grip</h2>
<p>The following screenshot shows the resize grip; I've highlighted it with a red circle.</p>
<div style="margin: 1em 0; text-align: center;"><img width="369" height="81" src="http://www.electrictoolbox.com/images/content/webkit-textarea-resizable.png" alt="resizeable textarea in webkit based browsers" /></div>
<p>The user can make the textarea larger but cannot size it back down below the original size.</p>
<h2>CSS to disable resizing</h2>
<p>The CSS to disable resizing for all textareas looks like this:</p>
<pre style="border: 1px #666 solid; padding: 10px; padding-bottom: 1em; overflow: hidden; overflow-x: auto; background: #eeeeee; font-size: 105%;">
textarea {
    resize: none;
}
</pre>
<p>You could instead just assign it to a single textarea by name (where the textarea HTML is &lt;textarea name=&quot;foo&quot;&gt;):</p>
<pre style="border: 1px #666 solid; padding: 10px; padding-bottom: 1em; overflow: hidden; overflow-x: auto; background: #eeeeee; font-size: 105%;">
textarea[name=foo] {
    resize: none;
}
</pre>
<p>Or by id (where the textarea HTML is &lt;textarea id=&quot;foo&quot;&gt;):</p>
<pre style="border: 1px #666 solid; padding: 10px; padding-bottom: 1em; overflow: hidden; overflow-x: auto; background: #eeeeee; font-size: 105%;">
#foo {
    resize: none;
}
</pre>
<h2>Validation errors</h2>
<p>The above is only supported by the webkit browsers. If you run it through a CSS validator (such as the <a href="http://jigsaw.w3.org/css-validator/">W3C CSS validator</a>) you'll get a warning like this:</p>
<pre style="border: 1px #666 solid; padding: 10px; padding-bottom: 1em; overflow: hidden; overflow-x: auto; background: #eeeeee; font-size: 105%;">
Property resize doesn't exist in CSS level 2.1 but exists in [css3] : none
</pre><div style="margin-top:10px; border-top:1px solid #ccc;">
<h2>Related posts:</h2>
<ul>
<li><a href='http://www.electrictoolbox.com/vertical-scrollbar-firefox-chrome-safari-opera/'>Always show a vertical scrollbar in Firefox, Chrome, Safari and Opera</a> (Saturday, June 20th 2009)</li>
<li><a href='http://www.electrictoolbox.com/fieldset-legend-tags-html-forms/'>Fieldset and legend tags in HTML forms</a> (Saturday, May 2nd 2009)</li>
<li><a href='http://www.electrictoolbox.com/using-label-tag-html-forms/'>Using the &lt;label&gt; tag for HTML forms</a> (Saturday, April 25th 2009)</li>
<li><a href='http://www.electrictoolbox.com/switch-off-autocomplete/'>Switch off autocomplete for an HTML form field</a> (Saturday, December 6th 2008)</li>
<li><a href='http://www.electrictoolbox.com/style-html-form-type-css-jquery/'>Style an HTML form input with CSS and jQuery</a> (Saturday, July 26th 2008)</li>
</ul>
</div>

<p><a href="http://feedads.g.doubleclick.net/~a/zcGGGa54gcpkhM8pMK-34Cy31DM/0/da"><img src="http://feedads.g.doubleclick.net/~a/zcGGGa54gcpkhM8pMK-34Cy31DM/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/zcGGGa54gcpkhM8pMK-34Cy31DM/1/da"><img src="http://feedads.g.doubleclick.net/~a/zcGGGa54gcpkhM8pMK-34Cy31DM/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ElectricToolboxBlog/~4/A6MQsvOH8y0" height="1" width="1"/>]]></content:encoded>
<feedburner:origLink>http://www.electrictoolbox.com/disable-textarea-resizing-safari-chrome/</feedburner:origLink></item>
<item>
<title>Count the words in a textarea or input with jQuery</title>
<link>http://feedproxy.google.com/~r/ElectricToolboxBlog/~3/2ZHfR7alkmM/</link>
<guid isPermaLink="false">http://www.electrictoolbox.com/jquery-count-words-textarea-input/</guid>
<pubDate>Thu, 02 Jul 2009 18:00:00 GMT</pubDate>
<description><![CDATA[<p>This post shows how to get a word count from an HTML textarea or text input using jQuery and display it on the page. The word count is updated as the user types.</p>]]></description>
<content:encoded><![CDATA[
<p>This post shows how to get a word count from an HTML textarea or text input using jQuery and display it on the page. The word count is updated as the user types.</p>
<h2>Example</h2>
<p>Here's a couple of examples. These won't work if you are reading this in a feed reader so you'll need to <a href="http://www.electrictoolbox.com/jquery-count-words-textarea-input/">click through</a> to read this post in a web browser.</p>
<form>
    <div id="example1_count" style="display: none;">&nbsp;</div>
    <textarea id="example1" rows="5" cols="50" class="example_word_count"></textarea>
    <div id="example2_count" style="display: none;">&nbsp;</div>
    <input type="text" id="example2" size="50" class="example_word_count" />
</form>
<script language="javascript">
function word_count(field, count) {

	var number = 0;
	var matches = $(field).val().match(/\b/g);
	if(matches) {
		number = matches.length/2;
	}
	$(count).text( number + ' word' + (number != 1 ? 's' : '') + ' approx');

}
$('.example_word_count').each(function() {
	var input = '#' + this.id;
	var count = input + '_count';
	$(count).show();
	word_count(input, count);
	$(this).keyup(function() { word_count(input, count) });
});
</script>
<h2>The HTML</h2>
<p>Here's the HTML form:</p>
<pre style="border: 1px #666 solid; padding: 10px; padding-bottom: 1em; overflow: hidden; overflow-x: auto; background: #eeeeee; font-size: 105%;">
&lt;form&gt;

&lt;div id=&quot;example1_count&quot; style=&quot;display:none&quot;&gt;&lt;/div&gt;
&lt;textarea id=&quot;example1&quot; rows=&quot;5&quot; cols=&quot;50&quot; class=&quot;word_count&quot;&gt;a b c&lt;/textarea&gt;

&lt;div id=&quot;example2_count&quot; style=&quot;display:none&quot;&gt;&lt;/div&gt;
&lt;input id=&quot;example2&quot; type=&quot;text&quot; size=&quot;50&quot; class=&quot;word_count&quot; /&gt;

&lt;/form&gt;
</pre>
<p>Note that the textarea and input have the class &quot;word_count&quot; and need to have id=&quot;...&quot;. The area that contains the word count is the same id plus &quot;_count&quot;. The divs containing the count are initially hidden (this would be better defined in a style sheet) and are made visible by the initialization code.</p>
<h2>The jQuery / Javascript</h2>
<p>When the document is ready all inputs with class word_count have an initial word count done to them and the word_count() function is bound to the keyup event. I tried this with the change event but that only fires when the user clicks/tabs out of the field.</p>
<pre style="border: 1px #666 solid; padding: 10px; padding-bottom: 1em; overflow: hidden; overflow-x: auto; background: #eeeeee; font-size: 105%;">
$(document).ready(function() {

    $('.word_count').each(function() {
        var input = '#' + this.id;
        var count = input + '_count';
        $(count).show();
        word_count(input, count);
        $(this).keyup(function() { word_count(input, count) });
    });

});

function word_count(field, count) {

    var number = 0;
    var matches = $(field).val().match(/\b/g);
    if(matches) {
        number = matches.length/2;
    }
    $(count).text( number + ' word' + (number != 1 ? 's' : '') + ' approx');

}
</pre>
<p>The word counts seem to be quite accurate using the \b word boundary, although in all browsers I tested .length returns twice the actual number, hence the division by 2.</p>
<p>The result from .match() are returned into a variable instead of just getting .length to prevent Javascripts errors being triggered in the browser if there are no matches.</p>
<p>The only issue I have found is if the user uses their mouse to copy and paste, select and delete, etc then the word count isn't updated. I couldn't find a satisfactory way to fix this.</p>
<h2>Browsers tested</h2>
<p>I have tested the above code in IE6, IE7, IE8, FF1, FF3.5, Chrome 2. It worked in all of them. I tested with 9000 words generated from <a href="http://lipsum.com/">lipsum.com</a> and it all worked nicely.</p><div style="margin-top:10px; border-top:1px solid #ccc;">
<h2>Related posts:</h2>
<ul>
<li><a href='http://www.electrictoolbox.com/jquery-form-elements-by-name/'>Accessing form elements by name with jQuery</a> (Tuesday, June 23rd 2009)</li>
<li><a href='http://www.electrictoolbox.com/jquery-clear-form/'>Clear a form with jQuery</a> (Friday, June 19th 2009)</li>
<li><a href='http://www.electrictoolbox.com/javascript-trim-ltrim-rtrim/'>Trimming strings with Javascript</a> (Tuesday, June 16th 2009)</li>
<li><a href='http://www.electrictoolbox.com/jquery-append-add-text-to-element/'>Use append() to add text/html to an element with jQuery</a> (Friday, June 5th 2009)</li>
<li><a href='http://www.electrictoolbox.com/jquery-change-default-value-on-focus/'>Changing the default text value on focus with jQuery</a> (Friday, May 29th 2009)</li>
</ul>
</div>

<p><a href="http://feedads.g.doubleclick.net/~a/ToQRLnLzaRWp5G2QHOLYh2QfvYA/0/da"><img src="http://feedads.g.doubleclick.net/~a/ToQRLnLzaRWp5G2QHOLYh2QfvYA/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/ToQRLnLzaRWp5G2QHOLYh2QfvYA/1/da"><img src="http://feedads.g.doubleclick.net/~a/ToQRLnLzaRWp5G2QHOLYh2QfvYA/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ElectricToolboxBlog/~4/2ZHfR7alkmM" height="1" width="1"/>]]></content:encoded>
<feedburner:origLink>http://www.electrictoolbox.com/jquery-count-words-textarea-input/</feedburner:origLink></item>
<item>
<title>Quarterly Update - April to June 2009</title>
<link>http://feedproxy.google.com/~r/ElectricToolboxBlog/~3/TFh6gEQS1P8/</link>
<guid isPermaLink="false">http://www.electrictoolbox.com/monthly-roundup/2009-06-quarterly/</guid>
<pubDate>Thu, 02 Jul 2009 15:00:00 GMT</pubDate>
<description><![CDATA[<p>At the start of this year I outlined <a href="http://www.electrictoolbox.com/aims-2009/">some goals for the year</a> for this blog. This included gowing the numbers of monthly pageviews from 60k to 600k and the number of RSS subscribers from 100 to 1000. Now that we're two quarters of the way through the year it's time to have another look and see how it's all going and if I'm on target.</p>]]></description>
<content:encoded><![CDATA[
<p>At the start of this year I outlined <a href="http://www.electrictoolbox.com/aims-2009/">some goals for the year</a> for this blog. This included gowing the numbers of monthly pageviews from 60k to 600k and the number of RSS subscribers from 100 to 1000. Now that we're two quarters of the way through the year it's time to have another look and see how it's all going and if I'm on target.</p>
<p>Please note there will be a second on-topic post (a jQuery one to do with counting words in a textarea or input field) later on today.</p>
<p>To achieve a tenfold gain like this requires a 21.15% increase month on month of pageviews and 21.65% month on month growth for RSS subscribers. As shown in the table below I'm getting it right with the RSS subscribers and I think the growth is realistic but I think it pretty unlikely I'll get to the 600k pageviews mark by the end of the year.</p>
<p>Traffic's been growing by around 15k pageviews per month since the start of the year so I've adjusted the &quot;required&quot; column for pageviews to a growth of 15k per month which results in 250k pageviews per month in December. I think this is more realistic.</p>
<table class="running">
    <tbody>
        <tr>
            <td>&nbsp;</td>
            <td align="center" colspan="3"><strong>Pageviews</strong></td>
            <td align="center" colspan="3"><strong>RSS Subscribers</strong></td>
        </tr>
        <tr>
            <td><strong>Month</strong></td>
            <td align="right"><strong>Required</strong></td>
            <td align="right"><strong>Actual</strong></td>
            <td align="right"><strong>Growth</strong></td>
            <td align="right"><strong>Required</strong></td>
            <td align="right"><strong>Actual</strong></td>
            <td align="right"><strong>Growth</strong></td>
        </tr>
        <tr>
            <td>December 2008</td>
            <td align="right">&nbsp;</td>
            <td align="right">60,073</td>
            <td align="right">&nbsp;</td>
            <td align="right">&nbsp;</td>
            <td align="right">95</td>
            <td align="right">&nbsp;</td>
        </tr>
        <tr>
            <td>January 2009</td>
            <td align="right">75,000</td>
            <td align="right">75,372</td>
            <td align="right">25.5%</td>
            <td align="right">116</td>
            <td align="right">115</td>
            <td align="right">21.1%</td>
        </tr>
        <tr>
            <td>February 2009</td>
            <td align="right">90,000</td>
            <td align="right">90,009</td>
            <td align="right">19.4%</td>
            <td align="right">141</td>
            <td align="right">150</td>
            <td align="right">30.4%</td>
        </tr>
        <tr>
            <td>March 2009</td>
            <td align="right">105,000</td>
            <td align="right">108,698</td>
            <td align="right">20.8%</td>
            <td align="right">172</td>
            <td align="right">165</td>
            <td align="right">10.0%</td>
        </tr>
        <tr>
            <td>April 2009</td>
            <td align="right">120,000</td>
            <td align="right">114,942</td>
            <td align="right">5.74%</td>
            <td align="right">209</td>
            <td align="right">200</td>
            <td align="right">21.2%</td>
        </tr>
        <tr>
            <td>May 2009</td>
            <td align="right">135,000</td>
            <td align="right">141,812</td>
            <td align="right">23.38%</td>
            <td align="right">&nbsp;254</td>
            <td align="right">240</td>
            <td align="right">&nbsp;20.0%</td>
        </tr>
        <tr>
            <td>June 2009</td>
            <td align="right">150,000</td>
            <td align="right">158,369</td>
            <td align="right">11.68%</td>
            <td align="right">309</td>
            <td align="right">310</td>
            <td align="right">29.2%</td>
        </tr>
        <tr>
            <td>July 2009</td>
            <td align="right">175,000</td>
            <td align="right">&nbsp;</td>
            <td align="right">&nbsp;</td>
            <td align="right">&nbsp;376</td>
            <td align="right">&nbsp;</td>
            <td align="right">&nbsp;</td>
        </tr>
        <tr>
            <td>August 2009</td>
            <td align="right">190,000</td>
            <td align="right">&nbsp;</td>
            <td align="right">&nbsp;</td>
            <td align="right">&nbsp;457</td>
            <td align="right">&nbsp;</td>
            <td align="right">&nbsp;</td>
        </tr>
        <tr>
            <td>September 2009</td>
            <td align="right">205,000</td>
            <td align="right">&nbsp;</td>
            <td align="right">&nbsp;</td>
            <td align="right">&nbsp;556</td>
            <td align="right">&nbsp;</td>
            <td align="right">&nbsp;</td>
        </tr>
        <tr>
            <td>October 2009</td>
            <td align="right">220,000</td>
            <td align="right">&nbsp;</td>
            <td align="right">&nbsp;</td>
            <td align="right">&nbsp;676</td>
            <td align="right">&nbsp;</td>
            <td align="right">&nbsp;</td>
        </tr>
        <tr>
            <td>November 2009</td>
            <td align="right">235,000</td>
            <td align="right">&nbsp;</td>
            <td align="right">&nbsp;</td>
            <td align="right">&nbsp;822</td>
            <td align="right">&nbsp;</td>
            <td align="right">&nbsp;</td>
        </tr>
        <tr>
            <td>December 2009</td>
            <td align="right">250,000</td>
            <td align="right">&nbsp;</td>
            <td align="right">&nbsp;</td>
            <td align="right">&nbsp;1000</td>
            <td align="right">&nbsp;</td>
            <td align="right">&nbsp;</td>
        </tr>
    </tbody>
</table>
<p>I'll update this again after the third quarter of the year, at the end of September.</p><div style="margin-top:10px; border-top:1px solid #ccc;">
<h2>Related posts:</h2>
<ul>
<li><a href='http://www.electrictoolbox.com/monthly-roundup/2009-06-statistics/'>Monthly Roundup - June 2009 - Statistics</a> (Thursday, July 2nd 2009)</li>
<li><a href='http://www.electrictoolbox.com/monthly-roundup/2009-06-posts/'>Monthly Roundup - June 2009 - Post Summary</a> (Wednesday, July 1st 2009)</li>
<li><a href='http://www.electrictoolbox.com/monthly-roundup/2009-03-quarterly/'>Quarterly Update - January to March 2009</a> (Friday, April 3rd 2009)</li>
<li><a href='http://www.electrictoolbox.com/aims-2009/'>Aims for 2009</a> (Monday, January 5th 2009)</li>
</ul>
</div>

<p><a href="http://feedads.g.doubleclick.net/~a/oqt4DuT4cvptptS_Qo8MThUv8HE/0/da"><img src="http://feedads.g.doubleclick.net/~a/oqt4DuT4cvptptS_Qo8MThUv8HE/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/oqt4DuT4cvptptS_Qo8MThUv8HE/1/da"><img src="http://feedads.g.doubleclick.net/~a/oqt4DuT4cvptptS_Qo8MThUv8HE/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ElectricToolboxBlog/~4/TFh6gEQS1P8" height="1" width="1"/>]]></content:encoded>
<feedburner:origLink>http://www.electrictoolbox.com/monthly-roundup/2009-06-quarterly/</feedburner:origLink></item>
<item>
<title>Google Analytics Data Export API updates July 1st 2009</title>
<link>http://feedproxy.google.com/~r/ElectricToolboxBlog/~3/7tWknqIwTVo/</link>
<guid isPermaLink="false">http://www.electrictoolbox.com/google-analytics-api-updates-20090701/</guid>
<pubDate>Thu, 02 Jul 2009 11:00:00 GMT</pubDate>
<description><![CDATA[<p>Just a quick note for all you Google Analytics API users out there that Google have made some updates to the API. The post on Google Groups <a href="http://groups.google.com/group/google-analytics-api-notify/browse_thread/thread/e8eb8f89bb86a6dd?hl=en">can be found here</a>, and I've also copied the information below.</p>]]></description>
<content:encoded><![CDATA[
<p>Just a quick note for all you Google Analytics API users out there that Google have made some updates to the API. The post on Google Groups <a href="http://groups.google.com/group/google-analytics-api-notify/browse_thread/thread/e8eb8f89bb86a6dd?hl=en">can be found here</a>, and I've also copied the information below.</p>
<p>1.  Some restrictions on dimension and metric combinations have been  relaxed. You can now query most content and visitor level dimensions  together, for example ga:pagePath and ga:source is now a valid  combination. Please see the updated reference guide for these new  combinations: <a href="http://code.google.com/apis/analytics/docs/gdata/gdataReferenceDimensionsMetrics.html#explore2Pair">http://code.google.com/apis/analytics/docs/gdata/gdataReferenceDimensionsMetrics.html#explore2Pair</a></p>
<p>2. The total number of rows that can be asked for in one request has  been increased to 10,000. The default is still 1000, but can now be  increased by setting the &quot;max-results&quot; query parameter.</p>
<p>3. The Account Feed now returns two new data elements for each table  id (currency and timezone)<br />
&lt;dxp:property name='ga:currency' value='USD'/&gt;<br />
&lt;dxp:property name='ga:timezone' value='America/Los_Angeles'/&gt;</p>
<p>4. We're now enforcing that data queries must include at least one  valid metric.</p>
<p>5. All previous deprecation changes have taken effect.</p>
<p>End of post from Google Groups.</p>
<p>I will check in the next few days to make sure none of these changes affect my <a href="http://www.electrictoolbox.com/google-analytics-api-and-php/">Google Analytics</a> API PHP Class and post any updates if there need to be any. I don't think off the top of my head that anything should need to be changed other than some of the documentation and examples.</p><div style="margin-top:10px; border-top:1px solid #ccc;">
<h2>Related posts:</h2>
<ul>
<li><a href='http://www.electrictoolbox.com/google-analytics-api-and-php/'>The Google Analytics API and PHP: A series</a> (Tuesday, April 28th 2009)</li>
</ul>
</div>

<p><a href="http://feedads.g.doubleclick.net/~a/7I2WNzAaEtEh87x_dynr8MOTCFs/0/da"><img src="http://feedads.g.doubleclick.net/~a/7I2WNzAaEtEh87x_dynr8MOTCFs/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/7I2WNzAaEtEh87x_dynr8MOTCFs/1/da"><img src="http://feedads.g.doubleclick.net/~a/7I2WNzAaEtEh87x_dynr8MOTCFs/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ElectricToolboxBlog/~4/7tWknqIwTVo" height="1" width="1"/>]]></content:encoded>
<feedburner:origLink>http://www.electrictoolbox.com/google-analytics-api-updates-20090701/</feedburner:origLink></item>
<item>
<title>Using PHP's glob() function to find files in a directory</title>
<link>http://feedproxy.google.com/~r/ElectricToolboxBlog/~3/zamytHq-J8I/</link>
<guid isPermaLink="false">http://www.electrictoolbox.com/php-glob-find-files/</guid>
<pubDate>Wed, 01 Jul 2009 18:00:00 GMT</pubDate>
<description><![CDATA[<p>A couple of weeks ago I posted how to read through a directory with PHP using the opendir() readdir() and closedir() functions and now look at the glob() function. glob() returns the filenames into an array and supports pattern matching so it can be very easy to find e.g. jpg images in a particular directory.</p>]]></description>
<content:encoded><![CDATA[
<p>A couple of weeks ago I posted how to <a href="http://www.electrictoolbox.com/php-read-through-directory/">read through a directory with PHP</a> using the opendir() readdir() and closedir() functions and now look at the glob() function. glob() returns the filenames into an array and supports pattern matching so it can be very easy to find e.g. jpg images in a particular directory.</p>
<h2>Example directory</h2>
<p>The examples below look at a directory with the following, the same example directory as used in the read through directory post:</p>
<pre style="border: 1px #666 solid; padding: 10px; padding-bottom: 1em; overflow: hidden; overflow-x: auto; background: #eeeeee; font-size: 105%;">
bar.txt       A regular file
baz           A directory
foo.txt       A regular file
link2foo.txt  A symbolic link to foo.txt
</pre>
<h2>Simple example</h2>
<p>To find all the files in the directory /path/to/directory with a .txt file extension, you can do this:</p>
<pre style="border: 1px #666 solid; padding: 10px; padding-bottom: 1em; overflow: hidden; overflow-x: auto; background: #eeeeee; font-size: 105%;">
$files = glob(&quot;/path/to/directory/*.txt&quot;);
</pre>
<p>The $files array contains the following from the example directory:</p>
<pre style="border: 1px #666 solid; padding: 10px; padding-bottom: 1em; overflow: hidden; overflow-x: auto; background: #eeeeee; font-size: 105%;">
Array
(
    [0] =&gt; /path/to/directory/bar.txt
    [1] =&gt; /path/to/directory/foo.txt
    [2] =&gt; /path/to/directory/link2foo.txt
)
</pre>
<p>If no files matched the pattern then the array will be empty.</p>
<h2>Example using braces</h2>
<p>There are flags which can be passed as a second optional parameter. One of these is GLOB_BRACE which means that e.g. {jpg,gif,png} will be expanded to match jpg, gif and png which can be useful if you need to look for a particular set of files by their extension, in this example for image files.</p>
<p>If the example directory also had the files 1.jpg, 2.gif and 3.png then you can do this to get glob to return just the image files:</p>
<pre style="border: 1px #666 solid; padding: 10px; padding-bottom: 1em; overflow: hidden; overflow-x: auto; background: #eeeeee; font-size: 105%;">
$files = glob(&quot;/path/to/directory/*.{jpg,gif,png}&quot;, GLOB_BRACE);
</pre>
<p>print_r($files) would echo:</p>
<pre style="border: 1px #666 solid; padding: 10px; padding-bottom: 1em; overflow: hidden; overflow-x: auto; background: #eeeeee; font-size: 105%;">
Array
(
    [0] =&gt; /path/to/directory/1.jpg
    [1] =&gt; /path/to/directory/2.gif
    [2] =&gt; /path/to/directory/3.png
)
</pre>
<h2>Further reading</h2>
<p>This serves as an introduction to using glob() to find files with PHP. Read the <a href="http://www.php.net/glob">glob manual page </a>for more details and for information about the other flags.</p><div style="margin-top:10px; border-top:1px solid #ccc;">
<h2>Related posts:</h2>
<ul>
<li><a href='http://www.electrictoolbox.com/php-read-through-directory/'>Reading through a directory with PHP</a> (Thursday, June 18th 2009)</li>
<li><a href='http://www.electrictoolbox.com/get-included-files-php/'>Get the included files with PHP</a> (Thursday, June 4th 2009)</li>
<li><a href='http://www.electrictoolbox.com/php-create-file-unique-name/'>Create a file with a unique name with PHP</a> (Thursday, February 28th 2008)</li>
</ul>
</div>

<p><a href="http://feedads.g.doubleclick.net/~a/wQ5X1HBbBX5C9y9IN3jekYxLV4g/0/da"><img src="http://feedads.g.doubleclick.net/~a/wQ5X1HBbBX5C9y9IN3jekYxLV4g/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/wQ5X1HBbBX5C9y9IN3jekYxLV4g/1/da"><img src="http://feedads.g.doubleclick.net/~a/wQ5X1HBbBX5C9y9IN3jekYxLV4g/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ElectricToolboxBlog/~4/zamytHq-J8I" height="1" width="1"/>]]></content:encoded>
<feedburner:origLink>http://www.electrictoolbox.com/php-glob-find-files/</feedburner:origLink></item>
<item>
<title>Monthly Roundup - June 2009 - Statistics</title>
<link>http://feedproxy.google.com/~r/ElectricToolboxBlog/~3/oR18dit_dVY/</link>
<guid isPermaLink="false">http://www.electrictoolbox.com/monthly-roundup/2009-06-statistics/</guid>
<pubDate>Wed, 01 Jul 2009 15:00:00 GMT</pubDate>
<description><![CDATA[<p>My monthly stats round up posts a summary of the most read posts over the previous month, numbers of visitors to the blog and any changes I have made over the month that may have affected visitor numbers etc. This is the monthly stats roundup for June 2009.</p>]]></description>
<content:encoded><![CDATA[
<p>My monthly stats round up posts a summary of the most read posts over the previous month, numbers of visitors to the blog and any changes I have made over the month that may have affected visitor numbers etc. This is the monthly stats roundup for June 2009.</p>
<p>Please note there will be a second post later on today with regular on-topic content.</p>
<h2>25 most popular articles in June 2009</h2>
<p>The following were the top 25 most accessed articles on this blog in June 2009, along with the original post date. The list is compiled using my PHP Class for the Google Analytics API to get the unique pageviews for posts in the month. Last month's rank is shown in square brackets after the post title, or [-] if it wasn't in the top 25 last month.</p>
<p>Note that unique pageviews means it's only counted once for each visitor so if someone views the page multiple times it's still only counted once for that user. If I sorted by pageviews the list would be slightly different with the Google Analytics API and PHP post in second position because people refer back to that page multiple times.</p>
<ol>
    <li><a href="http://www.electrictoolbox.com/jquery-get-set-form-values/">How to get and set form element values with jQuery</a> [1] (November 13th 2008)</li>
    <li><a href="http://www.electrictoolbox.com/article/apache/restart-apache/">Howto Restart Apache</a> [2] (December 22nd 2004)</li>
    <li><a href="http://www.electrictoolbox.com/php-http-referer-variable/">Using the HTTP_REFERER variable with PHP</a> [4] (April 18th 2008)</li>
    <li><a href="http://www.electrictoolbox.com/check-uncheck-checkbox-jquery/">How to check and uncheck a checkbox with jQuery</a> [5] (November 14th 2008)</li>
    <li><a href="http://www.electrictoolbox.com/article/mysql/delete-all-data-mysql/">Delete All Data in a MySQL Table</a> [3] (July 16th 2004)</li>
    <li><a href="http://www.electrictoolbox.com/jquery-cookies/">Setting cookies with jQuery</a> [-] (June 9th 2009)</li>
    <li><a href="http://www.electrictoolbox.com/article/mysql/cross-table-update/">Cross Table Update with MySQL</a> [7] (March 1st 2004)</li>
    <li><a href="http://www.electrictoolbox.com/article/networking/open-firewall-msn-icq/">Open firewall ports for MSN Messenger and ICQ</a> [8] (February 13th 2004)</li>
    <li><a href="http://www.electrictoolbox.com/install-yum-with-rpm-on-centos/">Install yum with rpm on CentOS</a> [11] (October 16th 2007)</li>
    <li><a href="http://www.electrictoolbox.com/windows-vista-black-screen-after-login/resolved/">Windows Vista Black Screen After Login - Resolved</a> [14] (June 26th 2008)</li>
    <li><a href="http://www.electrictoolbox.com/jquery-toggle-between-password-text-field/">jQuery: show plain text in a password field and then make it a regular password field on focus</a> [-] (June 2nd 2009)</li>
    <li><a href="http://www.electrictoolbox.com/article/linux-unix-bsd/howto-check-md5-file/">How to check an MD5 hash on a file</a> [9] (January 19th 2004)</li>
    <li><a href="http://www.electrictoolbox.com/google-analytics-api-and-php/">The Google Analytics API and PHP: A series</a> [6] (April 28th 2009)</li>
    <li><a href="http://www.electrictoolbox.com/windows-vista-black-screen-after-login/">Windows Vista Black Screen After Login</a> [17] (May 29th 2008)</li>
    <li><a href="http://www.electrictoolbox.com/upper-lower-case-strings-mysql/">Upper case and lower case strings with MySQL</a> [16] (July 29th 2008)</li>
    <li><a href="http://www.electrictoolbox.com/article/mysql/format-date-time-mysql/">Formatting Dates and Times with MySQL</a> [13] (July 17th 2004)</li>
    <li><a href="http://www.electrictoolbox.com/load-content-jquery-ajax-loading-image/">Loading content with jQuery AJAX - using a loading image</a> [15] (February 3rd 2009)</li>
    <li><a href="http://www.electrictoolbox.com/test-file-exists-bash-shell/">Test if a file exists with the BASH shell</a> [19] (August 27th 2008)</li>
    <li><a href="http://www.electrictoolbox.com/backup-export-bookmarks-mozilla-firefox-3/">Backup/export bookmarks with Mozilla Firefox 3</a> [22] (June 24th 2008)</li>
    <li><a href="http://www.electrictoolbox.com/user-not-assocated-trusted-sql-server-connection/">The user is not associated with a trusted SQL Server connection</a> [20] (June 21st 2008)</li>
    <li><a href="http://www.electrictoolbox.com/describe-table-structure-sql-server/">Describe table structure with MS SQL Server</a> [-] (July 23rd 2008)</li>
    <li><a href="http://www.electrictoolbox.com/article/linux-unix-bsd/create-rsa-dsa-keys-ssh/">Create RSA and DSA Keys for SSH</a> [18] (March 5th 2004)</li>
    <li><a href="http://www.electrictoolbox.com/style-html-form-type-css-jquery/">Style an HTML form input with CSS and jQuery</a> [-] (July 26th 2008)</li>
    <li><a href="http://www.electrictoolbox.com/class-soapclient-not-found/">PHP Error Class 'SoapClient' not found</a> [21] (September 25th 2007)</li>
    <li><a href="http://www.electrictoolbox.com/vertical-scrollbar-firefox-chrome-safari-opera/">Always show a vertical scrollbar in Firefox, Chrome, Safari and Opera</a> [-] (June 20th 2009)</li>
</ol>
<h2>Visitor numbers</h2>
<p>I get the visitor numbers from Google Analytics and saw an increase of 12.9% in visits and 11.7% in pageviews between May and June. The following table shows visits and pageviews for the six months from January 2009 to June 2009.<b><br />
</b></p>
<table>
    <tbody>
        <tr>
            <td><b>Month</b></td>
            <td align="right"><b>Visits</b></td>
            <td align="right"><b>Pageviews</b></td>
            <td align="right"><strong>PV Per Visit</strong></td>
        </tr>
        <tr>
            <td>January 2009</td>
            <td align="right">63,176</td>
            <td align="right">75,372</td>
            <td align="right">1.19</td>
        </tr>
        <tr>
            <td>February 2009</td>
            <td align="right">74,367</td>
            <td align="right">90,009</td>
            <td align="right">1.21</td>
        </tr>
        <tr>
            <td>March 2009</td>
            <td align="right">88,737</td>
            <td align="right">108,747</td>
            <td align="right">1.23</td>
        </tr>
        <tr>
            <td>April 2009</td>
            <td align="right">94,083</td>
            <td align="right">114,969</td>
            <td align="right">1.22</td>
        </tr>
        <tr>
            <td>May 2009</td>
            <td align="right">114,250</td>
            <td align="right">141,812</td>
            <td align="right">1.24</td>
        </tr>
        <tr>
            <td>June 2009</td>
            <td align="right">129,030</td>
            <td align="right">158,369</td>
            <td align="right">1.23</td>
        </tr>
    </tbody>
</table>
<h2>RSS Subscribers</h2>
<p>I use Feedburner/Google to serve my RSS feed and give an indication of visitor numbers. I curently have around 310 RSS subscribers, 70 more than last month.</p>
<h2>Changes made this month</h2>
<p>I've switched out the ad next to the Google Adsense block for a Buy Sell Ads square and added an advertising block utilising the same service in the right sidebar. If you are interested in advertising here please <a href="http://buysellads.com/buy/detail/8563">see my ads page</a> on Buy Sell Ads.</p><div style="margin-top:10px; border-top:1px solid #ccc;">
<h2>Related posts:</h2>
<ul>
<li><a href='http://www.electrictoolbox.com/monthly-roundup/2009-06-quarterly/'>Quarterly Update - April to June 2009</a> (Friday, July 3rd 2009)</li>
<li><a href='http://www.electrictoolbox.com/monthly-roundup/2009-06-posts/'>Monthly Roundup - June 2009 - Post Summary</a> (Wednesday, July 1st 2009)</li>
</ul>
</div>

<p><a href="http://feedads.g.doubleclick.net/~a/GOzbRplM8s1paQm0L7NNijGnSCY/0/da"><img src="http://feedads.g.doubleclick.net/~a/GOzbRplM8s1paQm0L7NNijGnSCY/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/GOzbRplM8s1paQm0L7NNijGnSCY/1/da"><img src="http://feedads.g.doubleclick.net/~a/GOzbRplM8s1paQm0L7NNijGnSCY/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ElectricToolboxBlog/~4/oR18dit_dVY" height="1" width="1"/>]]></content:encoded>
<feedburner:origLink>http://www.electrictoolbox.com/monthly-roundup/2009-06-statistics/</feedburner:origLink></item>
<item>
<title>Change the full text index minimum word length with MySQL</title>
<link>http://feedproxy.google.com/~r/ElectricToolboxBlog/~3/lj_OuEPdgyQ/</link>
<guid isPermaLink="false">http://www.electrictoolbox.com/mysql-full-text-index-word-length/</guid>
<pubDate>Tue, 30 Jun 2009 18:00:00 GMT</pubDate>
<description><![CDATA[<p>The MySQL full text index by default only indexes words which are 4 characters or longer, which means on a blog like mine if you search for &quot;PHP&quot; nothing will be returned. This post shows how to change minimum word length in MySQL so words or 3 characters (or even 2 if you want) can be indexed as well.</p>]]></description>
<content:encoded><![CDATA[
<p>The MySQL full text index by default only indexes words which are 4 characters or longer, which means on a blog like mine if you search for &quot;PHP&quot; nothing will be returned. This post shows how to change minimum word length in MySQL so words or 3 characters (or even 2 if you want) can be indexed as well.</p>
<p>Edit the MySQL configuration file my.cnf which is usually located on a *nix box at /etc/my.cnf or /etc/mysql/my.cnf and add the following line under the [mysqld] section to change the default to 3:</p>
<pre style="border: 1px #666 solid; padding: 10px; padding-bottom: 1em; overflow: hidden; overflow-x: auto; background: #eeeeee; font-size: 105%;">
ft_min_word_len = 3
</pre>
<p>If the ft_min_word_len value is already in the file then change the number to the minimum length required.</p>
<p>After making this change the MySQL server must be restarted for it to take effect. It is not possible to change the size with a set query (e.g. &quot;SET ft_min_word_len = 3&quot; which will result in the error &quot;#1193 - Unknown system variable 'ft_min_word_len'&quot;).</p>
<p>Now that the minimum word length has changed, and new or updated records will use the new minimum word length, but existing records will not be affected. To rebuild the full text index on a column for an example table called my_table, run this query:</p>
<pre style="border: 1px #666 solid; padding: 10px; padding-bottom: 1em; overflow: hidden; overflow-x: auto; background: #eeeeee; font-size: 105%;">
REPAIR TABLE my_table QUICK;
</pre>
<p>I have seen comments by some people who have suggested that on large tables it may be faster to drop the index and create it again depending on the size, and also that the repairing it may mean the query cache is not flushed whereas dropping and re-indexing will solve this.</p>
<p>Note however that if you drop the index and then re-create it you may get SQL query errors on your website. As always it is advisable to test this sort of thing out on a development server configured in the same way as a production server before doing it to the production server to ensure you don't have any issues.</p><div style="margin-top:10px; border-top:1px solid #ccc;">
<h2>Related posts:</h2>
<ul>
<li><a href='http://www.electrictoolbox.com/mysql-select-locate-substring/'>Selecting substrings with MySQL using LOCATE and SUBSTRING</a> (Wednesday, June 3rd 2009)</li>
<li><a href='http://www.electrictoolbox.com/mysql-select-locate/'>Finding the location of a string in a string with MySQL</a> (Wednesday, May 27th 2009)</li>
<li><a href='http://www.electrictoolbox.com/mysql-string-concatenation/'>String concatenation with MySQL</a> (Wednesday, March 4th 2009)</li>
<li><a href='http://www.electrictoolbox.com/maximum-length-mysql-text-field-types/'>Maximum length for MySQL TEXT field types</a> (Wednesday, February 4th 2009)</li>
<li><a href='http://www.electrictoolbox.com/mysql-table-storage-engine/'>How to tell which storage engine a MySQL table uses</a> (Tuesday, January 13th 2009)</li>
</ul>
</div>

<p><a href="http://feedads.g.doubleclick.net/~a/bEgNXIKOlNXDDhdgC5x5mCBxYBc/0/da"><img src="http://feedads.g.doubleclick.net/~a/bEgNXIKOlNXDDhdgC5x5mCBxYBc/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/bEgNXIKOlNXDDhdgC5x5mCBxYBc/1/da"><img src="http://feedads.g.doubleclick.net/~a/bEgNXIKOlNXDDhdgC5x5mCBxYBc/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ElectricToolboxBlog/~4/lj_OuEPdgyQ" height="1" width="1"/>]]></content:encoded>
<feedburner:origLink>http://www.electrictoolbox.com/mysql-full-text-index-word-length/</feedburner:origLink></item>
<item>
<title>Monthly Roundup - June 2009 - Post Summary</title>
<link>http://feedproxy.google.com/~r/ElectricToolboxBlog/~3/FsTXpzOFSgU/</link>
<guid isPermaLink="false">http://www.electrictoolbox.com/monthly-roundup/2009-06-posts/</guid>
<pubDate>Tue, 30 Jun 2009 15:00:00 GMT</pubDate>
<description><![CDATA[<p>At the start of each month I post a complete list of articles posted in the previous month. This is the monthly summary for June 2009.</p>]]></description>
<content:encoded><![CDATA[
<p>At the start of each month I post a complete list of articles posted in the previous month. This is the monthly summary for June 2009. This is followed up on the second day of the month (i.e. tomorrow) with statistics relating to visitor numbers and most popular posts for the previous month. </p>
<p>Please note there will be a second post later on today with regular on-topic content.</p>
<p>The posts made in June 2009 are as follows, broken down into categories. Note that some posts appear in more than one category so appear below more than once.</p>
<h2>Apache</h2>
<ul>
    <li><a href="http://www.electrictoolbox.com/password-protection-apache-htaccess/">Password protection with Apache and .htaccess</a> (22 Jun 2009)</li>
</ul>
<h2>Applications</h2>
<ul>
    <li><a href="http://www.electrictoolbox.com/set-country-microsoft-bing/">Setting the country with Microsoft Bing</a> (03 Jun 2009)</li>
    <li><a href="http://www.electrictoolbox.com/canon-easy-photoprint-cd-labelprint-errors-windows-7/">Canon Easy Photoprint and CD LabelPrint Errors on Windows 7</a> (09 Jun 2009)</li>
</ul>
<h2>HTML and CSS</h2>
<ul>
    <li><a href="http://www.electrictoolbox.com/style-select-optgroup-options-css/">Styling select, optgroup and options with CSS</a> (06 Jun 2009)</li>
    <li><a href="http://www.electrictoolbox.com/css-strikethrough/">How to do a strikethrough with CSS</a> (13 Jun 2009)</li>
    <li><a href="http://www.electrictoolbox.com/vertical-scrollbar-firefox-chrome-safari-opera/">Always show a vertical scrollbar in Firefox, Chrome, Safari and Opera</a> (20 Jun 2009)</li>
    <li><a href="http://www.electrictoolbox.com/grey-out-webpage/">Grey out a webpage</a> (26 Jun 2009)</li>
</ul>
<h2>Javascript</h2>
<ul>
    <li><a href="http://www.electrictoolbox.com/jquery-toggle-between-password-text-field/">jQuery: show plain text in a password field and then make it a regular password field on focus</a> (02 Jun 2009)</li>
    <li><a href="http://www.electrictoolbox.com/jquery-append-add-text-to-element/">Use append() to add text/html to an element with jQuery</a> (05 Jun 2009)</li>
    <li><a href="http://www.electrictoolbox.com/jquery-cookies/">Setting cookies with jQuery</a> (09 Jun 2009)</li>
    <li><a href="http://www.electrictoolbox.com/javascript-get-all-cookies/">Get all cookies with Javascript</a> (12 Jun 2009)</li>
    <li><a href="http://www.electrictoolbox.com/fckeditor-custom-styles/">Specify custom styles with FCKeditor</a> (14 Jun 2009)</li>
    <li><a href="http://www.electrictoolbox.com/javascript-trim-ltrim-rtrim/">Trimming strings with Javascript</a> (16 Jun 2009)</li>
    <li><a href="http://www.electrictoolbox.com/jquery-clear-form/">Clear a form with jQuery</a> (19 Jun 2009)</li>
    <li><a href="http://www.electrictoolbox.com/fckeditor-prevent-red-title-style/">Prevent &quot;Red Title&quot; showing in FCKEditor style drop down box</a> (21 Jun 2009)</li>
    <li><a href="http://www.electrictoolbox.com/jquery-form-elements-by-name/">Accessing form elements by name with jQuery</a> (23 Jun 2009)</li>
    <li><a href="http://www.electrictoolbox.com/grey-out-webpage/">Grey out a webpage</a> (26 Jun 2009)</li>
    <li><a href="http://www.electrictoolbox.com/jquery-facebox-greyed-background/">jQuery Facebox dialog with greyed out background</a> (27 Jun 2009)</li>
    <li><a href="http://www.electrictoolbox.com/fckeditor-select-language-example/">Select the FCKEditor language - full example</a> (28 Jun 2009)</li>
    <li><a href="http://www.electrictoolbox.com/jquery-facebox-loading-auto-center/">Make jQuery Facebox loading screen auto-center</a> (30 Jun 2009)</li>
</ul>
<h2>Miscellaneous Postings</h2>
<ul>
    <li><a href="http://www.electrictoolbox.com/accessory-geeks-june-coupons/">AccessoryGeeks June Coupons</a> (04 Jun 2009)</li>
    <li><a href="http://www.electrictoolbox.com/what-is-a-browser/">Yeah, what is a browser anyway?</a> (18 Jun 2009)</li>
    <li><a href="http://www.electrictoolbox.com/twitter-facebook/">Follow me on Twitter and Facebook</a> (18 Jun 2009)</li>
</ul>
<h2>MySql</h2>
<ul>
    <li><a href="http://www.electrictoolbox.com/mysql-select-locate-substring/">Selecting substrings with MySQL using LOCATE and SUBSTRING</a> (03 Jun 2009)</li>
    <li><a href="http://www.electrictoolbox.com/find-innodb-tables-mysql/">Find which tables use INNODB with MySQL</a> (10 Jun 2009)</li>
    <li><a href="http://www.electrictoolbox.com/mysql-innodb-one-file-per-table/">Use one file per table with MySQL's INNODB storage engine</a> (17 Jun 2009)</li>
    <li><a href="http://www.electrictoolbox.com/mysql-incorrect-key-file-for-table-error/">MySQL &quot;Incorrect key file for table&quot; error</a> (24 Jun 2009)</li>
</ul>
<h2>PHP</h2>
<ul>
    <li><a href="http://www.electrictoolbox.com/php-email-libraries/">List of PHP email libraries</a> (01 Jun 2009)</li>
    <li><a href="http://www.electrictoolbox.com/php-imap-functions/">Articles about how to use PHP's IMAP Functions</a> (01 Jun 2009)</li>
    <li><a href="http://www.electrictoolbox.com/get-included-files-php/">Get the included files with PHP</a> (04 Jun 2009)</li>
    <li><a href="http://www.electrictoolbox.com/paging-data-google-analytics-api-php-class/">Paging through result data from the Google Analytics API PHP Class</a> (08 Jun 2009)</li>
    <li><a href="http://www.electrictoolbox.com/google-analytics-api-page-bounce-rate/">Calculating a page's bounce rate with the Google Analytics API</a> (11 Jun 2009)</li>
    <li><a href="http://www.electrictoolbox.com/php-trim-function/">PHP's trim() function</a> (11 Jun 2009)</li>
    <li><a href="http://www.electrictoolbox.com/google-analytics-api-php-class-data-method-parameters/">Google Analytics API PHP Class data method parameters</a> (12 Jun 2009)</li>
    <li><a href="http://www.electrictoolbox.com/php-spl-autoload/">Autoloading with PHP's SPL library</a> (15 Jun 2009)</li>
    <li><a href="http://www.electrictoolbox.com/php-read-through-directory/">Reading through a directory with PHP</a> (18 Jun 2009)</li>
    <li><a href="http://www.electrictoolbox.com/php-curl-sending-username-password/">Sending a username and password with PHP CURL</a> (22 Jun 2009)</li>
    <li><a href="http://www.electrictoolbox.com/zend-framework-prevent-view-rendering/">Prevent a view rendering with the Zend Framework</a> (25 Jun 2009)</li>
    <li><a href="http://www.electrictoolbox.com/php-file-get-contents-sending-username-password/">Sending a username and password with PHP file_get_contents()</a> (29 Jun 2009)</li>
</ul>
<h2>VMWare</h2>
<ul>
    <li><a href="http://www.electrictoolbox.com/connect-usb-device-vmware-server-2/">Connect a USB device with VMWare Server 2</a> (05 Jun 2009)</li>
    <li><a href="http://www.electrictoolbox.com/vmware-infrastructure-web-access-address-port/">VMWare Infrastructure Web Access Address and Port</a> (07 Jun 2009)</li>
</ul>
<p>The second part of this monthly roundup, tomorrow, will look at the most popular posts read on the blog in June and some other stats. The next day will see a quarterly summary to see how my aims to date this year are going.</p><div style="margin-top:10px; border-top:1px solid #ccc;">
<h2>Related posts:</h2>
<ul>
<li><a href='http://www.electrictoolbox.com/monthly-roundup/2009-06-quarterly/'>Quarterly Update - April to June 2009</a> (Friday, July 3rd 2009)</li>
</ul>
</div>

<p><a href="http://feedads.g.doubleclick.net/~a/Xe71dUI-PRqB_zg3nw5rJZNKMWs/0/da"><img src="http://feedads.g.doubleclick.net/~a/Xe71dUI-PRqB_zg3nw5rJZNKMWs/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Xe71dUI-PRqB_zg3nw5rJZNKMWs/1/da"><img src="http://feedads.g.doubleclick.net/~a/Xe71dUI-PRqB_zg3nw5rJZNKMWs/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ElectricToolboxBlog/~4/FsTXpzOFSgU" height="1" width="1"/>]]></content:encoded>
<feedburner:origLink>http://www.electrictoolbox.com/monthly-roundup/2009-06-posts/</feedburner:origLink></item>
<item>
<title>Advertise on Chris Hope's LAMP Blog</title>
<link>http://feedproxy.google.com/~r/ElectricToolboxBlog/~3/gu2tJAHabRA/</link>
<guid isPermaLink="false">http://www.electrictoolbox.com/advertise/</guid>
<pubDate>Tue, 30 Jun 2009 02:00:00 GMT</pubDate>
<description><![CDATA[<p>I have added some ad spots on my blog through Buy Sell Ads. If you are interested in advertising here please <a href="http://www.electrictoolbox.com/advertiser-statistics/">click here</a> to view the advertiser information and statistics on my blog and <a href="http://buysellads.com/buy/detail/8563">click here</a> to go through to my listing at Buy Sell Ads to advertise.</p>]]></description>
<content:encoded><![CDATA[
<p>I have added some ad spots on my blog through Buy Sell Ads. If you are interested in advertising here please <a href="http://www.electrictoolbox.com/advertiser-statistics/">click here</a> to view the advertiser information and statistics on my blog and <a href="http://buysellads.com/buy/detail/8563">click here</a> to go through to my listing at Buy Sell Ads to advertise.</p><div style="margin-top:10px; border-top:1px solid #ccc;">
<h2>Related posts:</h2>
<ul>
<li><a href='http://www.electrictoolbox.com/advertiser-statistics/'>Advertiser Information and Statistics</a> (Tuesday, June 30th 2009)</li>
</ul>
</div>

<p><a href="http://feedads.g.doubleclick.net/~a/G6PoU5XEjVt0L1Bs44jfF6DvfLw/0/da"><img src="http://feedads.g.doubleclick.net/~a/G6PoU5XEjVt0L1Bs44jfF6DvfLw/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/G6PoU5XEjVt0L1Bs44jfF6DvfLw/1/da"><img src="http://feedads.g.doubleclick.net/~a/G6PoU5XEjVt0L1Bs44jfF6DvfLw/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ElectricToolboxBlog/~4/gu2tJAHabRA" height="1" width="1"/>]]></content:encoded>
<feedburner:origLink>http://www.electrictoolbox.com/advertise/</feedburner:origLink></item>
<item>
<title>Advertiser Information and Statistics</title>
<link>http://feedproxy.google.com/~r/ElectricToolboxBlog/~3/decb5udrUd8/</link>
<guid isPermaLink="false">http://www.electrictoolbox.com/advertiser-statistics/</guid>
<pubDate>Tue, 30 Jun 2009 00:00:00 GMT</pubDate>
<description><![CDATA[<p>Advertisers can advertise on my blog in two different positions. The first is 1 of 6 125x125 ad spots in the right sidebar, between the subscription information and the list of categories. This appears on all pages on this blog. The second is a single 300x250 ad spot that appears after the first paragraph on every page.</p>]]></description>
<content:encoded><![CDATA[
<p>Advertisers can advertise on my blog in two different positions. The first is 1 of 6 125x125 ad spots in the right sidebar, between the subscription information and the list of categories. This appears on all pages on this blog. The second is a single 300x250 ad spot that appears after the first paragraph on every page (which you can see directly below this paragraph).</p>
<p>This blog is currently getting around 150k+ pagviews per month and is currently getting around 5% to 10% growth each month. The statistics for the last 30 days and last six months are available below. These are automatically updated each day from Google Analytics using my <a href="http://www.electrictoolbox.com/google-analytics-api-and-php/">PHP Class for the GA API</a> and do not include my own visits, which are filtered out.</p>
<!-- generated content start -->	<table>
	    <tbody>
	        <tr>
	            <td><b>Month</b></td>
	            <td align="right"><b>Visits</b></td>
	            <td align="right"><b>Pageviews</b></td>
	        </tr><tr><td>Last 30 days</td><td align="right">131,775</td><td align="right">161,646</td></tr>
<tr><td>June 2009</td><td align="right">129,030</td><td align="right">158,389</td></tr>
<tr><td>May 2009</td><td align="right">114,250</td><td align="right">141,812</td></tr>
<tr><td>April 2009</td><td align="right">94,083</td><td align="right">114,969</td></tr>
<tr><td>March 2009</td><td align="right">88,737</td><td align="right">108,747</td></tr>
<tr><td>February 2009</td><td align="right">74,367</td><td align="right">90,009</td></tr>
<tr><td>January 2009</td><td align="right">63,176</td><td align="right">75,372</td></tr>
	    </tbody>
	</table><!-- generated content end -->
<p>If you would like to advertise on my blog please <a href="http://buysellads.com/buy/detail/8563">click through here</a> to my listing on Buy Sell Ads.</p>
<p><a href="http://feedads.g.doubleclick.net/~a/zuAs0rzazJDBe8qd0PaDr5JqWyE/0/da"><img src="http://feedads.g.doubleclick.net/~a/zuAs0rzazJDBe8qd0PaDr5JqWyE/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/zuAs0rzazJDBe8qd0PaDr5JqWyE/1/da"><img src="http://feedads.g.doubleclick.net/~a/zuAs0rzazJDBe8qd0PaDr5JqWyE/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ElectricToolboxBlog/~4/decb5udrUd8" height="1" width="1"/>]]></content:encoded>
<feedburner:origLink>http://www.electrictoolbox.com/advertiser-statistics/</feedburner:origLink></item>
<item>
<title>Make jQuery Facebox loading screen auto-center</title>
<link>http://feedproxy.google.com/~r/ElectricToolboxBlog/~3/Zlcrq0yCAgM/</link>
<guid isPermaLink="false">http://www.electrictoolbox.com/jquery-facebox-loading-auto-center/</guid>
<pubDate>Mon, 29 Jun 2009 18:00:00 GMT</pubDate>
<description><![CDATA[<p>I've been using the <a href="http://famspam.com/facebox">jQuery Facebox dialog plugin</a> in a couple of my projects and one thing that annoys me by default is the loading screen appears at an arbitrary position on the page and then becomes centered after the content has loaded; it's the moving after load I find messy. This post has a simple change that needs to be made to the Facebox code so it auto-centers the loading dialog.</p>]]></description>
<content:encoded><![CDATA[
<p>I've been using the <a href="http://famspam.com/facebox">jQuery Facebox dialog plugin</a> in a couple of my projects and one thing that annoys me by default is the loading screen appears at an arbitrary position on the page and then becomes centered after the content has loaded; it's the moving after load I find messy. This post has a simple change that needs to be made to the Facebox code so it auto-centers the loading dialog.</p>
<h2>The problem</h2>
<p>Here's a couple of screenshots to illustrate what I'm talking about.</p>
<p>The first shows the loading screen. It looks reasonably centered on the particular width the browser is but depending how wide the window is it appears more to the left or right.</p>
<p><img height="96" width="550" alt="facebox loading screen" src="http://www.electrictoolbox.com/images/content/facebox-loading.png" /></p>
<p>The second screenshot shows the dialog after it's loaded. At this point it is centered and if you compare this screenshot with the one above you can see they're in different positions. Unless the dialog loads instantly it will appear in one position and then shift when loaded. If it does load instantly then there may be a slight flicker as it moves after it is displayed.</p>
<p><img height="96" width="550" alt="facebox after loaded" src="http://www.electrictoolbox.com/images/content/facebox-loaded.png" /></p>
<h2>The solution</h2>
<p>There's a section of code in the facebox.js file which looks like this:</p>
<pre style="border: 1px #666 solid; padding: 10px; padding-bottom: 1em; overflow: hidden; overflow-x: auto; background: #eeeeee; font-size: 105%;">
$('#facebox').css({
  top:    getPageScroll()[1] + (getPageHeight() / 10),
  left:    385.5
}).show()
</pre>
<p>Change it to look like this:</p>
<pre style="border: 1px #666 solid; padding: 10px; padding-bottom: 1em; overflow: hidden; overflow-x: auto; background: #eeeeee; font-size: 105%;">
$('#facebox').css({
  top:    getPageScroll()[1] + (getPageHeight() / 10),
  left:   ($(window).width() - $('#facebox').width()) / 2
}).show()
</pre>
<p>Even if you change the width of the #facebox element in the stylesheet it will still auto-center on the page because it's calculating the position based on the width of the box determined programatically.</p><div style="margin-top:10px; border-top:1px solid #ccc;">
<h2>Related posts:</h2>
<ul>
<li><a href='http://www.electrictoolbox.com/jquery-facebox-greyed-background/'>jQuery Facebox dialog with greyed out background</a> (Saturday, June 27th 2009)</li>
<li><a href='http://www.electrictoolbox.com/grey-out-webpage/'>Grey out a webpage</a> (Friday, June 26th 2009)</li>
<li><a href='http://www.electrictoolbox.com/load-content-jquery-ajax-dealing-with-failures/'>Loading content with jQuery AJAX and dealing with failures</a> (Friday, February 6th 2009)</li>
</ul>
</div>

<p><a href="http://feedads.g.doubleclick.net/~a/nGVTHuUtOwevSMX6YgjZtiWW_UY/0/da"><img src="http://feedads.g.doubleclick.net/~a/nGVTHuUtOwevSMX6YgjZtiWW_UY/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/nGVTHuUtOwevSMX6YgjZtiWW_UY/1/da"><img src="http://feedads.g.doubleclick.net/~a/nGVTHuUtOwevSMX6YgjZtiWW_UY/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ElectricToolboxBlog/~4/Zlcrq0yCAgM" height="1" width="1"/>]]></content:encoded>
<feedburner:origLink>http://www.electrictoolbox.com/jquery-facebox-loading-auto-center/</feedburner:origLink></item>
<item>
<title>Sending a username and password with PHP file_get_contents()</title>
<link>http://feedproxy.google.com/~r/ElectricToolboxBlog/~3/n3aR39oXPWs/</link>
<guid isPermaLink="false">http://www.electrictoolbox.com/php-file-get-contents-sending-username-password/</guid>
<pubDate>Sun, 28 Jun 2009 18:00:00 GMT</pubDate>
<description><![CDATA[<p>Last week I looked at how send a username and password with PHP CURL. Using CURL is useful because you can examine the return information to see if the request was successful etc, but if your hosting provider doesn't have CURL for PHP enabled then you can still attempt to get the file by using file_get_contents and passing the authentication as part of the $context parameter.</p>]]></description>
<content:encoded><![CDATA[
<p>Last week I looked at how <a href="http://www.electrictoolbox.com/php-curl-sending-username-password/">send a username and password with PHP CURL</a>. Using CURL is useful because you can examine the return information to see if the request was successful etc, but if your hosting provider doesn't have CURL for PHP enabled then you can still attempt to get the file by using file_get_contents and passing the authentication as part of the $context parameter.</p>
<p>In the example below, $url is the web address you want to get data from, and $username and $password are the login credentials.</p>
<pre style="border: 1px #666 solid; padding: 10px; padding-bottom: 1em; overflow: hidden; overflow-x: auto; background: #eeeeee; font-size: 105%;">
$context = stream_context_create(array(
&nbsp;&nbsp;&nbsp; 'http' =&gt; array(
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 'header'  =&gt; &quot;Authorization: Basic &quot; . base64_encode(&quot;$username:$password&quot;)
    )
));
$data = file_get_contents($url, false, $context);
</pre>
<p>If the login details were incorrect, or you were attempting to access a password protected location and didn't pass any credentials at all, you'll see an error like this:</p>
<pre style="border: 1px #666 solid; padding: 10px; padding-bottom: 1em; overflow: hidden; overflow-x: auto; background: #eeeeee; font-size: 105%;">
Warning: file_get_contents(...): failed to open stream: HTTP request failed! 
HTTP/1.1 401 Authorization Required in ... on line 4
</pre>
<p>In future posts in this series I'll look at how to pass other headers along with a file_get_contents() request, for example how to send a form post. Again I would mention that it's probably better and easier to do this with CURL but if you must then it's possible with file_get_contents().</p><div style="margin-top:10px; border-top:1px solid #ccc;">
<h2>Related posts:</h2>
<ul>
<li><a href='http://www.electrictoolbox.com/php-curl-sending-username-password/'>Sending a username and password with PHP CURL</a> (Monday, June 22nd 2009)</li>
</ul>
</div>

<p><a href="http://feedads.g.doubleclick.net/~a/Np75E7N_GIJfyENFVrRF7hoijhk/0/da"><img src="http://feedads.g.doubleclick.net/~a/Np75E7N_GIJfyENFVrRF7hoijhk/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Np75E7N_GIJfyENFVrRF7hoijhk/1/da"><img src="http://feedads.g.doubleclick.net/~a/Np75E7N_GIJfyENFVrRF7hoijhk/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ElectricToolboxBlog/~4/n3aR39oXPWs" height="1" width="1"/>]]></content:encoded>
<feedburner:origLink>http://www.electrictoolbox.com/php-file-get-contents-sending-username-password/</feedburner:origLink></item>
<item>
<title>Select the FCKEditor language - full example</title>
<link>http://feedproxy.google.com/~r/ElectricToolboxBlog/~3/osq_ibTlGdY/</link>
<guid isPermaLink="false">http://www.electrictoolbox.com/fckeditor-select-language-example/</guid>
<pubDate>Sat, 27 Jun 2009 18:00:00 GMT</pubDate>
<description><![CDATA[<p>I had an email from someone asking about my &quot;Select the interface language in FCKEditor from a select box&quot; post and where they should put the Javascript and drop down box. This post shows the full PHP page required to display the FCKEditor with language selection drop down boxes.</p>]]></description>
<content:encoded><![CDATA[
<p>I had an email from someone asking about my &quot;Select the interface language in FCKEditor from a select box&quot; post and where they should put the Javascript and drop down box. This post shows the full PHP page required to display the FCKEditor with language selection drop down boxes.</p>
<p>The code does not contain the necessary work to save it to the database; it just shows how to have all the elements in your page.</p>
<p>A <a href="http://www.electrictoolbox.com/examples/fckeditor-language.php">working example</a> (using FCKEditor 2.6.2) can be found <a href="http://www.electrictoolbox.com/examples/fckeditor-language.php">here</a>.</p>
<p>And here is the code behind that page:</p>
<pre style="border: 1px #666 solid; padding: 10px; padding-bottom: 1em; overflow: hidden; overflow-x: auto; background: #eeeeee; font-size: 105%;">
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;FCKEditor Change Language Example&lt;/title&gt;
&lt;script language=&quot;javascript&quot;&gt;

function FCKeditor_OnComplete(editor) {
&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; var select = document.getElementById(&quot;languages&quot;);
&nbsp;&nbsp;&nbsp; for(lang in editor.Language.AvailableLanguages) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select.options[select.options.length] =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new Option(editor.Language.AvailableLanguages[lang], lang);
&nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp; select.value = editor.Language.ActiveLanguage.Code;
&nbsp;&nbsp;
}

function change_language(lang) {
&nbsp;&nbsp;&nbsp; window.location.href = window.location.pathname + &quot;?lang=&quot; + lang ;
}

&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;

&lt;select id=&quot;languages&quot; onchange=&quot;change_language(this.value);&quot;&gt;
&lt;/select&gt;
&lt;?php

require_once('fckeditor/fckeditor.php');

$oFCKeditor = new FCKeditor('html');
if(isset($_GET['lang'])) {
&nbsp;&nbsp;&nbsp; $oFCKeditor-&gt;Config['AutoDetectLanguage'] = false ;
    $oFCKeditor-&gt;Config['DefaultLanguage'] = $_GET['lang'] ;
}
else {
    $oFCKeditor-&gt;Config['AutoDetectLanguage'] = true ;
    $oFCKeditor-&gt;Config['DefaultLanguage'] = 'en' ;
}
$oFCKeditor-&gt;Create();

?&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre><div style="margin-top:10px; border-top:1px solid #ccc;">
<h2>Related posts:</h2>
<ul>
<li><a href='http://www.electrictoolbox.com/fckeditor-select-language-select-box/'>Select the interface language in FCKEditor from a select box</a> (Friday, March 6th 2009)</li>
<li><a href='http://www.electrictoolbox.com/javascript-add-options-html-select/'>Add options to an HTML select box with Javascript</a> (Tuesday, March 3rd 2009)</li>
<li><a href='http://www.electrictoolbox.com/language-selection-fckeditor/'>Language selection with FCKEditor</a> (Sunday, February 22nd 2009)</li>
<li><a href='http://www.electrictoolbox.com/fckeditor-paste-as-plain-text/'>Always make FCKEditor paste as plain text</a> (Tuesday, November 11th 2008)</li>
<li><a href='http://www.electrictoolbox.com/fckeditor-html-editor-php/'>Using the FCKEditor HTML Editor with PHP</a> (Wednesday, August 20th 2008)</li>
</ul>
</div>

<p><a href="http://feedads.g.doubleclick.net/~a/Lq0HFQkRpOVEDKSYkYaXLYz163w/0/da"><img src="http://feedads.g.doubleclick.net/~a/Lq0HFQkRpOVEDKSYkYaXLYz163w/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Lq0HFQkRpOVEDKSYkYaXLYz163w/1/da"><img src="http://feedads.g.doubleclick.net/~a/Lq0HFQkRpOVEDKSYkYaXLYz163w/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ElectricToolboxBlog/~4/osq_ibTlGdY" height="1" width="1"/>]]></content:encoded>
<feedburner:origLink>http://www.electrictoolbox.com/fckeditor-select-language-example/</feedburner:origLink></item>
<item>
<title>jQuery Facebox dialog with greyed out background</title>
<link>http://feedproxy.google.com/~r/ElectricToolboxBlog/~3/M2Kn-Wp8GSI/</link>
<guid isPermaLink="false">http://www.electrictoolbox.com/jquery-facebox-greyed-background/</guid>
<pubDate>Fri, 26 Jun 2009 18:00:00 GMT</pubDate>
<description><![CDATA[<p>Yesterday I posted how to grey out a web page which is useful when showing a Javascript dialog box and in this post show how to do the same when using the jQuery Facebox plugin. The Facebox plugin makes dialog boxes that look like the ones in Facebook.</p>]]></description>
<content:encoded><![CDATA[
<div>
<link rel="stylesheet" type="text/css" href="http://www.electrictoolbox.com/examples/facebox/facebox.css" /> <script language="javascript" src="/examples/facebox/facebox.js"></script> <script language="javascript">
   	$("body").append("<div id='opaque' style='display: none;'></div>");

    $(document).bind('loading.facebox', function() {
    	$("#opaque").show();
	});
    $(document).bind('close.facebox', function() {
    	$("#opaque").hide();
	});
	$(document).bind('afterReveal.facebox', function() {
		// this is a fix for IE6 which resets the height to 100% of the window height
		$("#opaque").height($(document).height());
	});
</script></div>
<p>Yesterday I posted how to <a href="http://www.electrictoolbox.com/grey-out-webpage/">grey out a web page</a> which is useful when showing a Javascript dialog box and in this post show how to do the same when using the <a href="http://famspam.com/facebox">jQuery Facebox plugin</a>. The Facebox plugin makes dialog boxes that look like the ones in Facebook.</p>
<p>By default the Facebox plugin just positions the dialog box in the window and doesn't change the background at all; by making the background greyed out it gives more focus to the popup.</p>
<h2>Example</h2>
<p>First of all, an example to show you what I mean. Click the &quot;Open Facebox Dialog&quot; button below and the Facebox dialog box will open and the web page will become greyed out thanks to an opaque layer that will be made visible.</p>
<form>
    <input type="button" onclick="jQuery.facebox('OK, you can close me now')" value="Open Facebox Dialog" />
</form>
<p>Note that if you are viewing this post in an RSS reader you'll need to <a href="http://www.electrictoolbox.com/jquery-facebox-greyed-background/">click through</a> to view it in a web browser to make the above button work.</p>
<h2>The code</h2>
<p>You'll need to get the <a href="http://famspam.com/facebox">Facebox plugin </a>and then can use the following Javascript code to make the above work:</p>
<pre style="border: 1px #666 solid; padding: 10px; padding-bottom: 1em; overflow: hidden; overflow-x: auto; background: #eeeeee; font-size: 105%;">
$(&quot;body&quot;).append(&quot;&lt;div id='opaque' style='display: none;'&gt;&lt;/div&gt;&quot;);

$(document).bind('loading.facebox', function() {
&nbsp;&nbsp;&nbsp; $(&quot;#opaque&quot;).show();
});
$(document).bind('close.facebox', function() {
&nbsp;&nbsp;&nbsp; $(&quot;#opaque&quot;).hide();
});
$(document).bind('afterReveal.facebox', function() {
&nbsp;&nbsp;&nbsp; // this is a fix for IE6 which resets the height to 100% of the window height
&nbsp;&nbsp;&nbsp; $(&quot;#opaque&quot;).height($(document).height());
});
</pre>
<p>The opaque div is appended to the document in the jQury code above (or you could alternatively code it into the HTML, but this saves having to do it) and then showing and hiding the opaque layer is bound to the facebox dialog as it loads and closes.</p>
<p>The afterRevel.facebox binding is a fix for IE6 which changes the height of the opaque div after the facbox div is loaded; the fix changes it back to the full document height.</p>
<h2>CSS for #opaque</h2>
<p>The CSS required for the #opaque layer is as follows:</p>
<pre style="border: 1px #666 solid; padding: 10px; padding-bottom: 1em; overflow: hidden; overflow-x: auto; background: #eeeeee; font-size: 105%;">
#opaque {
    position: fixed;
    top: 0px;
    left: 0px;
    width: 100%;
    height: 100%;
    z-index: 99;
    display: none;
    background-color: black;
    filter: alpha(opacity=40);
    opacity: 0.4;
}
</pre>
<p>You can adjust the opacity values and background-color to suit yourself to make the opaque layer more or less dark.</p><div style="margin-top:10px; border-top:1px solid #ccc;">
<h2>Related posts:</h2>
<ul>
<li><a href='http://www.electrictoolbox.com/jquery-facebox-loading-auto-center/'>Make jQuery Facebox loading screen auto-center</a> (Tuesday, June 30th 2009)</li>
<li><a href='http://www.electrictoolbox.com/grey-out-webpage/'>Grey out a webpage</a> (Friday, June 26th 2009)</li>
</ul>
</div>

<p><a href="http://feedads.g.doubleclick.net/~a/fLz27Zw1Zv-Wb26Kt3rpTHFyQ4A/0/da"><img src="http://feedads.g.doubleclick.net/~a/fLz27Zw1Zv-Wb26Kt3rpTHFyQ4A/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/fLz27Zw1Zv-Wb26Kt3rpTHFyQ4A/1/da"><img src="http://feedads.g.doubleclick.net/~a/fLz27Zw1Zv-Wb26Kt3rpTHFyQ4A/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ElectricToolboxBlog/~4/M2Kn-Wp8GSI" height="1" width="1"/>]]></content:encoded>
<feedburner:origLink>http://www.electrictoolbox.com/jquery-facebox-greyed-background/</feedburner:origLink></item>
<item>
<title>Grey out a webpage</title>
<link>http://feedproxy.google.com/~r/ElectricToolboxBlog/~3/5FuBS8VlVtc/</link>
<guid isPermaLink="false">http://www.electrictoolbox.com/grey-out-webpage/</guid>
<pubDate>Thu, 25 Jun 2009 18:00:00 GMT</pubDate>
<description><![CDATA[<p>When showing an inline popup in a webpage (as opposed to a popup window) it is nice to grey out the background a little to highlight that the user should now interact with the popup rather than the webpage. This post shows how to do the necessary HTML and CSS to achieve this and tomorrow's post will look at implementing the greyed out background with the <a href="http://famspam.com/facebox">jQuery Facebox plug-in</a>.</p>]]></description>
<content:encoded><![CDATA[
<p>When showing an inline popup in a webpage (as opposed to a popup window) it is nice to grey out the background a little to highlight that the user should now interact with the popup rather than the webpage. This post shows how to do the necessary HTML and CSS to achieve this and tomorrow's post will look at implementing the greyed out background with the <a href="http://famspam.com/facebox">jQuery Facebox plug-in</a>.</p>
<p>A simple way to achieve this is to have an opaque/transparent div which takes up 100% of the window and has a z-index so it appears above everything except for the inline popup. The example presented here works in IE 6.0+, FF 1.0+, Opera 9.0+ (I haven't tried it it in older versions), Chrome 2.0+, and Safari 3.2 + 4.0 on Windows (I haven't tested it in older versions of Safari but it may work)</p>
<p>The CSS for doing this is as follows:</p>
<pre style="border: 1px #666 solid; padding: 10px; padding-bottom: 1em; overflow: hidden; overflow-x: auto; background: #eeeeee; font-size: 105%;">
#opaque {
    position: fixed;
    top: 0px;
    left: 0px;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: none;
    background-color: black;
    filter: alpha(opacity=30);
    opacity: 0.3;
}
* html #opaque {
    position: absolute;
}
</pre>
<p>The extra position: absolute at the end is to make it work in Internet Explorer 6.</p>
<p>The opacity of the div is set with &quot;filter: ...&quot; for Internet Explorer and &quot;opacity: ...&quot; for the other browsers. The lower the number the more opaque the layer. You can experiment with different background colors and opacity levels to make the &quot;greyed out&quot; webpage colored how you want it.</p>
<p>Then all you need in the webpage itself is the following empty div:</p>
<pre style="border: 1px #666 solid; padding: 10px; padding-bottom: 1em; overflow: hidden; overflow-x: auto; background: #eeeeee; font-size: 105%;">
&lt;div id=&quot;opaque&quot;&gt;&lt;/div&gt;
</pre>
<p>It can go anywhere in the web page and can also be added using Javascript.</p>
<p>Note that if you attempt to validate the CSS against a CSS validator that it will fail the &quot;filter: ...&quot; part because it's an Internet Explorer thing and not part of any standard, and it may warn about the &quot;opacity: ...&quot; part because it's only available officially from CSS v3.</p>
<p>See an <a href="http://www.electrictoolbox.com/examples/grey-out-webpage.html">example of this working here</a> and <a href="http://www.electrictoolbox.com/jquery-facebox-greyed-background/">tomorrow's post</a> will have a more comprehensive example using an actual popup window.</p><div style="margin-top:10px; border-top:1px solid #ccc;">
<h2>Related posts:</h2>
<ul>
<li><a href='http://www.electrictoolbox.com/jquery-facebox-loading-auto-center/'>Make jQuery Facebox loading screen auto-center</a> (Tuesday, June 30th 2009)</li>
<li><a href='http://www.electrictoolbox.com/jquery-facebox-greyed-background/'>jQuery Facebox dialog with greyed out background</a> (Saturday, June 27th 2009)</li>
</ul>
</div>

<p><a href="http://feedads.g.doubleclick.net/~a/NUyiij-fy6VDTTvCBJFNJXI9D1Q/0/da"><img src="http://feedads.g.doubleclick.net/~a/NUyiij-fy6VDTTvCBJFNJXI9D1Q/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/NUyiij-fy6VDTTvCBJFNJXI9D1Q/1/da"><img src="http://feedads.g.doubleclick.net/~a/NUyiij-fy6VDTTvCBJFNJXI9D1Q/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ElectricToolboxBlog/~4/5FuBS8VlVtc" height="1" width="1"/>]]></content:encoded>
<feedburner:origLink>http://www.electrictoolbox.com/grey-out-webpage/</feedburner:origLink></item>
<item>
<title>Prevent a view rendering with the Zend Framework</title>
<link>http://feedproxy.google.com/~r/ElectricToolboxBlog/~3/VL1T4JXP2Ao/</link>
<guid isPermaLink="false">http://www.electrictoolbox.com/zend-framework-prevent-view-rendering/</guid>
<pubDate>Wed, 24 Jun 2009 18:00:00 GMT</pubDate>
<description><![CDATA[<p>The front controller of the Zend Framework will render a view by default but it's possible to disable this automatic rendering should you need to, for example if making an Ajax call which sends some JSON data instead of an HTML template.</p>]]></description>
<content:encoded><![CDATA[
<p>The front controller of the Zend Framework will render a view by default but it's possible to disable this automatic rendering should you need to, for example if making an Ajax call which sends some JSON data instead of an HTML template.</p>
<p>In the action simply add the following line of code and it will not render the view:</p>
<pre style="border: 1px #666 solid; padding: 10px; padding-bottom: 1em; overflow: hidden; overflow-x: auto; background: #eeeeee; font-size: 105%;">
$this-&gt;_helper-&gt;viewRenderer-&gt;setNoRender(true);
</pre><div style="margin-top:10px; border-top:1px solid #ccc;">
<h2>Related posts:</h2>
<ul>
<li><a href='http://www.electrictoolbox.com/php-zend-registry/'>Using the Zend_Registry in PHP</a> (Monday, January 19th 2009)</li>
<li><a href='http://www.electrictoolbox.com/php-method-chaining/'>Method chaining with PHP</a> (Sunday, December 7th 2008)</li>
<li><a href='http://www.electrictoolbox.com/sending-email-zend-mail/'>Sending email with Zend_Mail</a> (Saturday, August 23rd 2008)</li>
<li><a href='http://www.electrictoolbox.com/database-error-handling-zend-framework/'>Database error handling with the Zend Framework</a> (Sunday, May 11th 2008)</li>
<li><a href='http://www.electrictoolbox.com/zend-framework-controller-router-example/'>Zend Framework Controller Router example</a> (Saturday, April 12th 2008)</li>
</ul>
</div>

<p><a href="http://feedads.g.doubleclick.net/~a/XHMzFq3ig7TKDC9g2KtENz284bM/0/da"><img src="http://feedads.g.doubleclick.net/~a/XHMzFq3ig7TKDC9g2KtENz284bM/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/XHMzFq3ig7TKDC9g2KtENz284bM/1/da"><img src="http://feedads.g.doubleclick.net/~a/XHMzFq3ig7TKDC9g2KtENz284bM/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ElectricToolboxBlog/~4/VL1T4JXP2Ao" height="1" width="1"/>]]></content:encoded>
<feedburner:origLink>http://www.electrictoolbox.com/zend-framework-prevent-view-rendering/</feedburner:origLink></item>
<item>
<title>MySQL "Incorrect key file for table" error</title>
<link>http://feedproxy.google.com/~r/ElectricToolboxBlog/~3/dUp0DP5LAiA/</link>
<guid isPermaLink="false">http://www.electrictoolbox.com/mysql-incorrect-key-file-for-table-error/</guid>
<pubDate>Tue, 23 Jun 2009 18:00:00 GMT</pubDate>
<description><![CDATA[<p>When saving a record to a MySQL table the other day I got the error message &quot;Incorrect key file for table 'mytable'; try to repair it&quot;. I am uncertain why the error occured and how to ensure it doesn't happen again in the future but a quick fix for the time being is simple.</p>]]></description>
<content:encoded><![CDATA[
<p>When saving a record to a MySQL table the other day I got the error message &quot;Incorrect key file for table 'mytable'; try to repair it&quot;. I am uncertain why the error occured and how to ensure it doesn't happen again in the future but a quick fix for the time being is simple.</p>
<p>All you need to do is to repair the table by running the following SQL command, where &quot;mytable&quot; is the name of the table that gave the error:</p>
<pre style="border: 1px #666 solid; padding: 10px; padding-bottom: 1em; overflow: hidden; overflow-x: auto; background: #eeeeee; font-size: 105%;">
REPAIR TABLE `mytable`;
</pre>
<p>You can run this from e.g. the <a href="http://www.electrictoolbox.com/running-queries-mysql-command-line/">MySQL CLI</a> or <a href="http://www.electrictoolbox.com/article/mysql/phpMyAdmin/">phpMyAdmin</a>. From phpMyAdmin select the table, then &quot;Operations&quot; from the navigation tabs in the right frame above the table info; then &quot;Repair Table&quot; from the &quot;Table maintenance&quot; options at the bottom of the page.</p><div style="margin-top:10px; border-top:1px solid #ccc;">
<h2>Related posts:</h2>
<ul>
<li><a href='http://www.electrictoolbox.com/mysql-show-indexes-table/'>Show indexes for a table with MySQL</a> (Wednesday, April 15th 2009)</li>
<li><a href='http://www.electrictoolbox.com/mysql-optimize-table-phpmyadmin/'>Optimize a table in MySQL from phpMyAdmin</a> (Saturday, September 6th 2008)</li>
<li><a href='http://www.electrictoolbox.com/running-queries-mysql-command-line/'>Running queries from the MySQL Command Line</a> (Wednesday, April 16th 2008)</li>
<li><a href='http://www.electrictoolbox.com/article/mysql/phpMyAdmin/'>phpMyAdmin</a> (Wednesday, December 10th 2003)</li>
</ul>
</div>

<p><a href="http://feedads.g.doubleclick.net/~a/UlZ6vcPvwbw6bfFFV_2xh-YjVC0/0/da"><img src="http://feedads.g.doubleclick.net/~a/UlZ6vcPvwbw6bfFFV_2xh-YjVC0/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/UlZ6vcPvwbw6bfFFV_2xh-YjVC0/1/da"><img src="http://feedads.g.doubleclick.net/~a/UlZ6vcPvwbw6bfFFV_2xh-YjVC0/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ElectricToolboxBlog/~4/dUp0DP5LAiA" height="1" width="1"/>]]></content:encoded>
<feedburner:origLink>http://www.electrictoolbox.com/mysql-incorrect-key-file-for-table-error/</feedburner:origLink></item>
<item>
<title>Accessing form elements by name with jQuery</title>
<link>http://feedproxy.google.com/~r/ElectricToolboxBlog/~3/wsIhtYQJbpE/</link>
<guid isPermaLink="false">http://www.electrictoolbox.com/jquery-form-elements-by-name/</guid>
<pubDate>Mon, 22 Jun 2009 18:00:00 GMT</pubDate>
<description><![CDATA[<p>There are a variety of ways to access elements with jQuery including by the name property of form elements (the name=&quot;&quot; part of &lt;input name=&quot;foo&quot;&gt;). This can be useful so you don't have to assign an id to each and every form element as well as a name which is needed to pass the form value to the next page.</p>]]></description>
<content:encoded><![CDATA[
<p>There are a variety of ways to access elements with jQuery including by the name property of form elements (the name=&quot;&quot; part of &lt;input name=&quot;foo&quot;&gt;). This can be useful so you don't have to assign an id to each and every form element as well as a name which is needed to pass the form value to the next page.</p>
<h2>Example form</h2>
<p>Here's a snippet of a form for the following examples with first_name and last_name fields in a form.</p>
<pre style="border: 1px #666 solid; padding: 10px; padding-bottom: 1em; overflow: hidden; overflow-x: auto; background: #eeeeee; font-size: 105%;">
&lt;form ... &gt;
    ....
    &lt;input type=&quot;text&quot; name=&quot;first_name&quot; value=&quot;&quot; /&gt;
    &lt;input type=&quot;text&quot; name=&quot;last_name&quot; value=&quot;&quot; /&gt;
    ....
&lt;/form&gt;
</pre>
<h2>Selecting by name</h2>
<p>To select the &quot;first_name&quot; text input form element do this:</p>
<pre style="border: 1px #666 solid; padding: 10px; padding-bottom: 1em; overflow: hidden; overflow-x: auto; background: #eeeeee; font-size: 105%;">
$(&quot;input[name=first_name]&quot;);</pre>
<p>For example to display the value in an alert window do this:</p>
<pre style="border: 1px #666 solid; padding: 10px; padding-bottom: 1em; overflow: hidden; overflow-x: auto; background: #eeeeee; font-size: 105%;">
alert( $(&quot;input[name=first_name]&quot;).val() );</pre>
<p>To speed up the process so your jQuery code doesn't have to traverse the entire DOM looking for the element you could define the &lt;form&gt; itself with an ID (e.g. &lt;form id=&quot;myform&quot;&gt;) and do this:</p>
<pre style="border: 1px #666 solid; padding: 10px; padding-bottom: 1em; overflow: hidden; overflow-x: auto; background: #eeeeee; font-size: 105%;">
alert( $(&quot;#myform input[name=first_name]&quot;).val() );</pre>
<h2>Deprecated @</h2>
<p>Prior to jQuery 1.3 you could do this:</p>
<pre style="border: 1px #666 solid; padding: 10px; padding-bottom: 1em; overflow: hidden; overflow-x: auto; background: #eeeeee; font-size: 105%;">
$(&quot;input[@name=first_name]&quot;)</pre>
<p>However the @ syntax was deprecated in jQuery 1.2 and removed in jQuery 1.3, so don't use it when using jQuery 1.2 and up.</p><div style="margin-top:10px; border-top:1px solid #ccc;">
<h2>Related posts:</h2>
<ul>
<li><a href='http://www.electrictoolbox.com/jquery-clear-form/'>Clear a form with jQuery</a> (Friday, June 19th 2009)</li>
<li><a href='http://www.electrictoolbox.com/check-uncheck-checkbox-jquery/'>How to check and uncheck a checkbox with jQuery</a> (Friday, November 14th 2008)</li>
<li><a href='http://www.electrictoolbox.com/jquery-get-set-form-values/'>How to get and set form element values with jQuery</a> (Thursday, November 13th 2008)</li>
</ul>
</div>

<p><a href="http://feedads.g.doubleclick.net/~a/FjmoOoyiGoF-CuOgPfNnr-43TQE/0/da"><img src="http://feedads.g.doubleclick.net/~a/FjmoOoyiGoF-CuOgPfNnr-43TQE/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/FjmoOoyiGoF-CuOgPfNnr-43TQE/1/da"><img src="http://feedads.g.doubleclick.net/~a/FjmoOoyiGoF-CuOgPfNnr-43TQE/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ElectricToolboxBlog/~4/wsIhtYQJbpE" height="1" width="1"/>]]></content:encoded>
<feedburner:origLink>http://www.electrictoolbox.com/jquery-form-elements-by-name/</feedburner:origLink></item>
<item>
<title>Sending a username and password with PHP CURL</title>
<link>http://feedproxy.google.com/~r/ElectricToolboxBlog/~3/Dmihyx-e5_0/</link>
<guid isPermaLink="false">http://www.electrictoolbox.com/php-curl-sending-username-password/</guid>
<pubDate>Sun, 21 Jun 2009 18:00:00 GMT</pubDate>
<description><![CDATA[<p>CURL and PHP combined can be really useful for getting data from websites, connecting to APIs (such as the <a href="http://www.electrictoolbox.com/google-analytics-api-and-php/">Google Analytics API</a>) and so on. Sometimes you may need to connect to a website that is password protected so this post looks at how to pass the username and password with PHP and CURL.</p>]]></description>
<content:encoded><![CDATA[
<p>CURL and PHP combined can be really useful for getting data from websites, connecting to APIs (such as the <a href="http://www.electrictoolbox.com/google-analytics-api-and-php/">Google Analytics API</a>) and so on. Sometimes you may need to connect to a website that is password protected so this post looks at how to pass the username and password with PHP and CURL.</p>
<p>If the following example, $url is the url to connect to and $username and $password contain your authorization details:</p>
<pre style="border: 1px #666 solid; padding: 10px; padding-bottom: 1em; overflow: hidden; overflow-x: auto; background: #eeeeee; font-size: 105%;">
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, &quot;$username:$password&quot;);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
</pre>
<p>The &quot;curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);&quot; line is not actually necessary but it means the HTML from the web page returned goes into the $output variable rather than echoed out to standard output.</p>
<p>Likewise you don't necessarily need to do &quot;$info = curl_getinfo($ch);&quot; but it does contain useful information about the HTTP status and so on. Doing print_r($info) from the above example on the script I used for writing and testing this post outputs the following:</p>
<pre style="border: 1px #666 solid; padding: 10px; padding-bottom: 1em; overflow: hidden; overflow-x: auto; background: #eeeeee; font-size: 105%;">
Array
(
    [url] =&gt; http://www.testing.local/auth/
    [content_type] =&gt; text/html;charset=UTF-8
    [http_code] =&gt; 200
    [header_size] =&gt; 208
    [request_size] =&gt; 100
    [filetime] =&gt; -1
    [ssl_verify_result] =&gt; 0
    [redirect_count] =&gt; 0
    [total_time] =&gt; 0.022493
    [namelookup_time] =&gt; 0.000279
    [connect_time] =&gt; 0.000475
    [pretransfer_time] =&gt; 0.000487
    [size_upload] =&gt; 0
    [size_download] =&gt; 732
    [speed_download] =&gt; 32543
    [speed_upload] =&gt; 0
    [download_content_length] =&gt; 732
    [upload_content_length] =&gt; 0
    [starttransfer_time] =&gt; 0.022389
    [redirect_time] =&gt; 0
)
</pre>
<p>Getting the http_code from the information is useful so you know if it successfully connected to the page before parsing any of the return data.</p><div style="margin-top:10px; border-top:1px solid #ccc;">
<h2>Related posts:</h2>
<ul>
<li><a href='http://www.electrictoolbox.com/php-file-get-contents-sending-username-password/'>Sending a username and password with PHP file_get_contents()</a> (Monday, June 29th 2009)</li>
<li><a href='http://www.electrictoolbox.com/password-protection-apache-htaccess/'>Password protection with Apache and .htaccess</a> (Monday, June 22nd 2009)</li>
<li><a href='http://www.electrictoolbox.com/google-analytics-login-php-curl-username-password/'>Log into the Google Analytics API using PHP and CURL using Username/Password Authentication</a> (Thursday, April 23rd 2009)</li>
<li><a href='http://www.electrictoolbox.com/fix-undefined-function-curl-init-php-debian/'>Fix the &quot;call to undefined function curl_init&quot; error in PHP on Debian</a> (Friday, April 17th 2009)</li>
</ul>
</div>

<p><a href="http://feedads.g.doubleclick.net/~a/1-yN_FZaHD7i0Qx7sd9HQmWnqjs/0/da"><img src="http://feedads.g.doubleclick.net/~a/1-yN_FZaHD7i0Qx7sd9HQmWnqjs/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/1-yN_FZaHD7i0Qx7sd9HQmWnqjs/1/da"><img src="http://feedads.g.doubleclick.net/~a/1-yN_FZaHD7i0Qx7sd9HQmWnqjs/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ElectricToolboxBlog/~4/Dmihyx-e5_0" height="1" width="1"/>]]></content:encoded>
<feedburner:origLink>http://www.electrictoolbox.com/php-curl-sending-username-password/</feedburner:origLink></item>
</channel>
</rss>
