A blog about me, my doings and everything I think deserves attention.

First personal contact

Mentioned previously, I have some disagreements with my current university. For not leaving out the positive parts I have to say that the prompt reaction after my blog post is very appreciated. Prior to the meeting I had with the administration today, the big relief had already settled in, that and C# are not the only ways to a bachelor degree. We in fact are allowed to code with whatever we want and for now I think we have to choose PHP or C# for an exam project. This hopefully will not be the case on the day I leave this place.

So in contrast to my previous university, my blog post had an impact, I was listened to and encouraged to help to improve this, although the general happiness about the post itself was limited.

This is definitely and environment I can work with. Correcting the link from the previous post, that was sent to us ( I have no received the correct link which leads to a framework, that is supposed to make cross platform API involving development easier: Does anyone have any experience with this framework?

Wrapping up, it was a nice first day and I’m looking forward to doing cool stuff with interesting people.

Give me the first comment

PHP explode and implode

I think PHP is one of the few place where you can explode and implode without being a terrorist but still have fun with it. At least explode() is one of my favourite functions in PHP :).

For this little quick tip I actually have a quite practical use case I stumbled upon a couple of days ago. The jQueryUI datepicker widget. It lets the user pick a date, which you automatically can insert into a form. You can define different formats like day day, month month, year year and so on, whatever makes you happy, but to save it in a MySQL database you might want to convert it to the typical yyyy-mm-dd format. For that we spread the string we pull from the form at 2 different places (where the datepicker sets the slashes).


Exploding may sound a little extreme in the beginning, but it’s just a function to split a string into an array at certain points.

$explodeable = '28/05/2011';
$exploded = explode('/',$explodeable);

// generates output:

Array ( [0] => 28 [1] => 05 [2] => 2011 )


Now, we still have to get the year, month and day together again to put it in a MySQL DATE or DATETIME field, so let’s look at the solutions we have for that with implode. Implode just puts a string together from an array with or without a certain character between them.

$exploded = array_reverse($exploded);

// generates output:
Array ( [0] => 2011 [1] => 05 [2] => 28 )

$imploded = implode('-', $exploded);
echo $imploded

// generates output:

For this it works perfectly, but you can also chain the different values of an array as following, if array_reverse can’t do the job and you want to sort your entries manually. This solution gives you more flexibility, also with the characters in between the split values.

$chained = $exploded[2].'-'.$exploded[1].'-'.$exploded[0];
echo chained;

// generates output:

Thanks for reading my little quick tip on date conversion between the jQueryUI and MySQL, have a nice time everybody icon smile PHP explode and implode

Only 1 comment so far

CodeIgniter, my personal ignition

ci logo flame CodeIgniter, my personal ignitionOkay folks, I should tell you, I’m not missing any limbs, my apartment wasn’t on fire and not even my computer. Anyways I have been digging into the PHP framework CodeIgniter. Originally CI was brought to my attention by Kenneth and recently I picked up a project that really screamed for dynamic structure, scalability and classes with some built-in security features.

What I think is remarkably positive about the framework, is that the user guide actually is shipped with it, so you easily can start learning it without constantly being on the net.

CodeIgniter does well what frameworks should do. Distribute versatile tools for faster development of common tasks. It’s like a workbench for webdevs.

The first thing I noticed when I was watching the series of video tutorials on called CodeIgniter from Scratch, that the naming conventions have been changed. To be fair it has to be said, that these video tutorials were submitted in 2009.

What exactly changed?

The internal naming conventions of classes!

// before:
class Site extends Controller {
    function foo(){

// now:
class Site extends CI_Controller {
    function foo(){

If you don’t take this into account you’ll receive error messages like:

Fatal error: Class ‘Controller’ not found

Now if you think I’m paid by the tutsplus guys, you’re wrong, but still here’s a list of chapters, covered in the video lessons:
Overview of chapters:

  1. Getting Started With the Framework
  2. Database Selecting Methods
  3. Sending EmailsNewsletter
  4. Signup
  5. CRUD
  6. Login
  7. Pagination
  8. AJAX
  9. File Uploading and Image Manipulation
  10. The Calendar Library
  11. File and Directory Operations
  12. Shopping Cart
  13. Extending the Framework
  14. Security
  15. Profiling, Benchmarking and Hooks
  16. Displaying & Sorting Tabular Data
  17. Search Results without Query Strings

You don’t have to watch them in this order, because mostly you can learn independently about the separate chapters. Though I would recommend, that you in any case start out with 1, because it also gives you an idea how the model, view, controller (MVC) pattern works.

I really thank the author, Jeffrey Way, for making this series. He’s done very well, although sometimes not everything is planned out, facebook is accidentally open, typos happen and sometimes windows are switched to switch back again. This all still makes it authentic and the quality of the screen cast is improving with every episode.

I’m not through with all the videos, but so far I can really recommend them.

EDIT: Wed May  4 03:00:48 CEST 2011
I just noticed, that in episode 6 there was an error I could not easily overcome. I got the following error message:
Fatal error: Call to undefined method CI_Controller::Controller() in /Users/gero/Sites/my_proj/application/controllers/site.php on line 7

file: site.php

// before:
function __construct()

// fix:
function __construct()

Simply change the Controller to __construct and you’re going again. In the CI forums it’s recommended to use a library for authentication though.

2 comments already

First website and navigation with PHP

This little tutorial will teach you how to build a website with multiple pages with PHP. When I started trying to make websites, I used frames/iframes which are BAD and not valid html code. So we now we want to use the PHP function include(), which gives us the ability to display other documents inside another.

So let’s start out with a standard xhtml document called index.php:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “”>
<html xmlns=”” xml:lang=”en” lang=”en”>
<title>Navigation with PHP</title>

Before the doctype we now insert a list of our files. Let’s say we have files called “news.php” “home.php” and “about.php”.

$section = array();
$section[‘home’] = “home.php”;
$section[‘news’] = “news.php”;
$section[‘about’] = “about.php”;?>

Now this “list” actually puts all these as entries into an array in PHP. We’ll need that later. Now we head down to the <body> tag and insert some php code here. What we’ve done until now is only creating a list with the files we may want to show inside our website. So if we want to display our content, we should add the next part where you want the content to appear.

<div id=”content”><?php
if (isset($_GET[‘section’], $section[$_GET[‘section’]])) {
include $section[$_GET[‘section’]];
} else {
include $section[‘home’];

Now our website has the ability to include the listed files and make them appear as a part of the site. I’ve already created a <div> around it, you don’t have to do that. The last thing to do is to add the navigation with the links that tells the PHP script which file to load. If there are no or no valid options given, it does include $section[‘home’];. This first of all makes the script include home.php when only index.php is opened and makes the site safer, because no not listed files can be included like /etc/passwd. icon wink First website and navigation with PHP

<li><a href=”index.php?section=home”>Home</a></li>
<li><a href=”index.php?section=news”>News</a></li>
<li><a href=”index.php?section=about”>About</a></li>

I’ve already put the links in a list, you don’t have to do that, but it looks nicer. The part between the <a> and </a> is the essential one. Through opening index.php?section=news you tell the index.php to include the file saved with the array entry news.

That’s basically it. You’ve learned how to avoid frames and create a website with multiple pages!

Give me the first comment

coding projects

I’ve got ideas for coding projects involving PHP, MySQL and Ruby. I know that I need more practice, but I really would like to set up a dictionary server for me and parts of my frenchclass. We could not find a good open source library for french->german, german->french. I would like to create a database, that would be able to be converted into a textfile, readable by ding, an open source, linux dictionary application. I have never started a database project before, so this is going to be fun. I’ll need a server that is available 24/7 or at least mostly. The amount of traffic will not be large, so I would be really happy if someone would offer me a user and one or two databases on his/her server. Since this is not very likely to happen, I will set up a low-end server by the end of the month and find some place for it.

Learning ruby is fun. I try to drag other people in it and some of them seem to be interested. I think I’m making progress in small steps and I’m looking forward to the integration of Ruby in The Gimp, so I some day maybe will be able to write Gimp extensions in Ruby.

related links:

Google soc The Gimp

Google soc Ruby central

Ding dictionary

Give me the first comment