Friday, March 30, 2012

Scroll page with javascript

Sometimes it's useful to scroll the page automatically to send users to certain parts of the page. To do that the easiest way is using javascript, more specifically jquery that is a javascript framework.

Test it here:

Scroll down!
Example code:

function scroll_up()
function scroll_to_last_div()
<div style="height:100px;width:400px;">
<a href="javascript:scroll_to_last_div();">Scroll to last div!</a>
<div style="height:600px;width:400px;background:#234a34;">
<div style="height:100px;width:400px;" id="last_div">
<a href="javascript:scroll_up();">Scroll to top!</a>
<div style="height:600px;width:400px;background:#fa342a;">

Monday, March 19, 2012

Insert one or multiple rows in mysql db using php

Normally, one of the first thing that you need to do after connect to a mysql database is insert data. This tutorial is about inserting a single row or multiple rows into a mysql database using php. If you don't know how to connect to a database check our previous tutorial "Connect to a mysql database using php".

Let's imagine for this example that my table name is "people" and inside this table i have 3 columns "id", "first_name" and " last_name".

This way to insert a single row with the person "Chuck Norris" i need to execute the following query:

$validation = mysql_query("INSERT INTO platform_types 
                         (id, first_name, last_name) 
                         VALUES ('1', 'Chuck', 'Norris')"

if (!$validation) //test query for errors 
    echo("Error in query: " . mysql_errno($apbl_db_con) . ": " 
    . mysql_error($apbl_db_con) . '
//Closing connection (don't forget to close the connection 
//when you don't need to query stuff to the db)

The $db_con variable is the one returned by mysql_connect when you connect to the database. If you need to insert multiple rows at same time the procedure is the same but you add more values at the end like this:

$validation = mysql_query("INSERT INTO platform_types 
    (id, first_name, last_name) VALUES 
    ('1', 'Chuck', 'Norris'), 
    ('2', 'Jackie', 'Chan')",$db_con);

//...the rest of the code it's the same.
 Notice that if your "id" column is set to auto-increment (usually is) you don't need to give a value to the "id" in the query because it will auto-increment by him self. Then your query will look like this:

$validation = mysql_query("INSERT INTO platform_types 
    (first_name, last_name) VALUES 
    ('Chuck', 'Norris'), 
    ('Jackie', 'Chan')",$db_con);

//...the rest of the code it's the same.

Thursday, March 15, 2012

Connect to a mysql database using php

In almost all web projects now a days you need to use at least one database to store information. So let's start using a database! First step is to connect to the database.
For this example let's imagine that a i have mysql running on the adress "localhost" with the username "root" and password "password". The database name is "mydatabase".

With this information we can start coding our php script to connect with the database.

I hope it has been helpful, in the next tutorial let's see how to insert data on your  mysql database using php.

//Try to connect to database
$con = mysql_connect('localhost','root','password'); 
if (!$con) //Test if connection was successfully
    echo ('Error on connect: ' . mysql_errno() . ": " 
    . mysql_error());
    //Connect to the table inside the database
    $db_check = mysql_select_db('mydatabase', $con); 
    if (!$db_check)
        echo ('Error on the database : ' . mysql_errno() 
        . ": " . mysql_error());

Next tutorial:  "Insert one or multiple rows in mysql db using php".

Sunday, March 11, 2012

ShutItDown RBS Review

Following my last post about licensing free and open source software, today i will review on of my applications that i just released for free under the GNU GPL v3 license. Both the application and the code written in Visual Basic are available to download.

ShutItDown RBS

ShutItDown RBS is a software that allows the user to schedule task like shut down, restart or log off on his machine. You can specify date and time and even specify if you want them to repeat every day or every week.

  • Quickly shut down, restart or log off your pc.
  • Schedule shut down, restart or log off tasks in your pc.
  • Able to run minimized and start automatically with windows.
  • You can schedule daily or weekly tasks and they will be performed automatically until you disable them.
  • Automatically generated log of ShutItDown activities so that you can check if certain tasks were performed.

shutitdown free and open source

User guide video:

This software was already approved in several websites like,, and

So if you are into programming and sometimes you develop some applications, why not share them with world?

ShutItDown RBS website 
ShutItDown RBS sourceforge project

Tuesday, March 6, 2012

How to license your free software with GNU GPL v3

As you all know a software license is something that tells the users what they can or cannot do with that especific software and it's also a way of giving some credit to the author for his software.

There are several types of licenses:

- Perpetual license
- Subscription license
- Freeware license
- Shareware license
- OEM (original equipment manufacturer)
- Educational or Academic Software
- Not for Resale (NFR) Software License
- And more...

This post is specifically about Freeware Licences and specially about Open Source because, as you already know, inside free software applications we have some that are open source and others that are closed source.

So let's see a little bit more about free and open source software (quoting
A primary consequence of the free software form of licensing is that acceptance of the license is essentially optional — the end-user may use, study, and privately modify the software without accepting the license. However, if the user wishes to exercise the right of redistributing the software, then the end-user must accept, and be bound by, the software license.
Free and open-source licenses generally fall under two categories: Those with the aim to have minimal requirements about how the software can be redistributed (permissive licenses), and those that aim to preserve the freedoms that is given to the users by ensuring that all subsequent users recives those rights (copyleft Licenses).
An example of a copyleft free software license is the GNU General Public License (GPL). This license is aimed at giving all user unlimited freedom to use, study, and privately modify the software, and if the user adheres to the terms and conditions of GPL, freedom to redistribute the software or any modifications to it. For instance, any modifications made and redistributed by the end-user must include the source code for these, and the license of any derivative work must not put any additional restrictions beyond what GPL allows.[1]
Examples of permissive free software licenses are the BSD license and the MIT license, which give unlimited permission to use, study, and privately modify the software, and includes only minimal requirements on redistribution. This gives a user the permission to take the code and use it as part of closed-source software or software released under a proprietary software license.

free and open source license GPL

One of the most known and used license for this type of software is the GNU GPL(General Public License) that is now on version 3. The bases of this license, quoting, are:

The Foundations of the GPL

Nobody should be restricted by the software they use. There are four freedoms that every user should have:
  • the freedom to use the software for any purpose,
  • the freedom to change the software to suit your needs,
  • the freedom to share the software with your friends and neighbors, and
  • the freedom to share the changes you make.
When a program offers users all of these freedoms, we call it free software.
Developers who write software can release it under the terms of the GNU GPL. When they do, it will be free software and stay free software, no matter who changes or distributes the program. We call this copyleft: the software is copyrighted, but instead of using those rights to restrict users like proprietary software does, we use them to ensure that every user has freedom.
So if you developed a software and you are thinking about distributing it as a free software, i created a little video explaning what you need to do to license your software with GNU GPL v3. I am not an expert on this but i have already done this and i am just trying to share my experience.

Video turorial: