This is a note to self.  When you see Warning: Invalid argument supplied for foreach() in /home/yourdom/public_html/libraries/joomla/database/database/mysqli.php on line 391 it means the host has run out of disk space on the tmp folder used for sessions and other temporary files.  Specifically Joomla is trying to create a temporary table and it appears it gets as far as creating the pointer and php/mysql errors at the point of reading the data rather than at the point of adding data to the table.

So if you are not me and you have this error then the solution is to ask your host to clear out the /tmp folder and increase the amount of disk space allocated to it so it doesn’t happen again.

 

A short function to extract numbers from a string in PHP using a regular expression.

function extract_numbers($string) {
	preg_match_all('/([\d]+)/', $string, $match);
	return $match[0];
}

This function returns numbers in an array. See The Bit Repository for more details.  Kudos to Gabriel C for a straight forward solution.

 

The following PHP code repairs databases that show an overhead. Remove the errorlog function if not required.

<?php
$sql = "SHOW TABLE STATUS";
$result = mysql_query($sql) or errorlog( __LINE__."\n\n".mysql_error()."\n\n$sql");
if($result && mysql_num_rows($result)) {
  while($row = mysql_fetch_assoc($result)) {
    if($row['Data_free'] > 0) {
      $sql = "REPAIR TABLE ".$row['Name'].";";
      $repair = mysql_query($sql) or errorlog( __LINE__."\n\n".mysql_error()."\n\n$sql");		
      if($repair) {
        echo "<br /><em>".$row['Name']." succesfully repaired</em>";
      } else {
        echo "<br /><strong>".$row['Name']." error: ".mysql_error()."</strong>";
      }
    }
  }	
}
 
//Stub
function errorlog($msg) { echo $msg; }
 
?>
 

mypph 300x228 Using twitter as an alerting platformI received an email from Clickatell inviting me to top up my SMS account.  After a split second consideration I realised I did not need them anymore.  Sorry Clickatell!

Twitter is more convenient.  I have set up a few private accounts and subscribed to them through my own.  When an event occurs I receive notification direct to my phone as a free SMS message direct from twitter.

Although twitter has been unreliable lately it has proven more convenient than using Clickatell.  In time twitter will fix the problems and they may even be suitable for mission critical solutions.  I hope so because they are easy to use and should spawn many superb product ideas all designed to keep us informed with the information we want now, not just when we visit facebook.




 

homepage 150x150 Payment Processing for OnelogbookOnelogbook is an outdoor sports activity program currently in development. My task was to add Paypal payment processing to the joining form.

Technologies used were PHP, MySQL, Javascript and I created a few minor graphics. Payment information is sent to Paypal for processing. On successful payment Paypal return IPN (Instant Payment Notification) code to the website and the user is authorised to use the website extended features.

Javascript is used for form validation and PHP provides the server side code. If a payment is cancelled user details are removed from memory and the database is not updated (you can see the cancellation notice at the end of this short high speed video).

And a “Please Wait” graphic – scourge of Paypal Payment Processing!

pleasewait Payment Processing for Onelogbook

 

Styleroomz asked for a widget to showcase products. Data is retrieved from their affiliate source as XML in a zip file.

The XML is updated daily to ensure prices and special offers are fresh.

The widget uses HTML, XML, MySQL, Javascript and PHP. Data sources include XML for the affiliate information such as coded links, pictures, pricing and store information, and MySQL used by the Styleroomz ecommerce software to link to their pages. The Yui library from Yahoo was used to create the carousel effect.

The following short video demonstrates how the widget in use.

 

search results 300x230 Redesigning Styleroomz Product SearchI was given the opportunutiy to alter the search results layout for Styleroomz.com, a fashion website for dress sizes between 16 and 20.  The improved search design required alterations to PHP and Javascript.

 

Click here to download the Terry Pratchett Quotes WordPress Plugin/widget.

If you are a fan of Terry Pratchett then how can you resist a free Terry Pratchett Quotes plugin windget?  To install download the pratchett.zip unpack to your hard drive and then upload the pratchett folder to your WordPress plugins folder.  After activating the plugin go to your Widgets (in the Appearance menu) and drag it to your sidebar.

The widget adopts your template design automatically and displays quotes at random.


Moist Von Lipwig by ~rhianimated on deviantART

 

I just helped with some of the Javascript behind a twitter and Google Mashup called Questioon.

questioon Do you have any Questioons?

Currently available only on the .co.uk but Tunde, the owner, intends to update the .com soon.  Some of the features I added include:

  • A default set of 7 searches on the front page (called quick links)
  • Default searches replaces with the last 7 searches you made
  • Ability to delete an individual search
  • Ability to reset all quick links
  • Used Juitter to embed twitter feed on the results page

The design was created by another developer.

 

With growing frequency cut and paste operations include a link and several carriage returns that I did not select. You might see something like “Read more: http://www…”

Injecting stuff I don’t want into my clipboard operation is unwelcome and a serious invasion of my privacy.

The author of a blog page understandably wants more visitors and recognition for their effort but contaminating established processes such as cut and paste is not the way to go about it.

There is plenty of evidence that manipulating established processes that involve web user privacy will have a derogatory effect. Injecting stuff I don’t want into my clipboard operation is unwelcome and a serious invasion of my privacy.

I decided to modify my hosts file and block access to tynt and the domains they use. Immediately afterwards, like a breath of fresh air, my activity with the web appeared to be more efficient.

Surely the improvement is not because the occasional cut and paste operation was contaminated? I could not figure why productivity “felt” so much better.

Another question is how the heck did they get Javascript to contaminate the paste buffer to begin with? Javascript is not supposed to have access to the clipboard without permission.

A little investigation revealed that tynt use this feature to “Drive Traffic”, “Improve Search Rank” and “Measure Management”. In other words extract cpu cycles from your computer or cell to satisfy the curiosity of the blogger and the people behind tynt.

With the tynt domain blocked sites load faster and you are no longer feeding them your personal information.

Some of the websites using this code are:-

  • KillerStartups
  • Wired
  • Timeout
  • National Geographic
  • Times
  • The New Yorker
  • Smithsonian
  • Daily Mail
  • Daily News
  • Timeout
  • Evening Express

And a growing number of blogs.

Add the following two lines to your hosts file to stop links being added to your cut and paste operations over many blogs and news sites:

127.0.0.1 tynt.com
127.0.0.1 tcr.tynt.com

(See http://uhit.us/ntqp to find out how to edit your hosts file)

© 2011 Martyn Walker | Software Architect | Hiker And Hacker Suffusion theme by Sayontan Sinha