Sunday, April 5, 2009

Wedding of two SLIIT Batchmates

How fast the time pass by. 3 years ago we were so free. Now we have been sucked into the race of making money and to the Zombie Theory ;-)

This photo was taken around 2006

SLIIT Group Project Team

This is now 2009 April



I wish all the best for Shiksha and Saveen.

Wednesday, April 1, 2009

Get php time diff (time diffence)

Following code will show you how to get time difference in second from a two datetime values. Remember datetime should be in this format: yyyy-mm-dd hr:min:sec

$dbdate_seconds = strtotime($dbdate);
$inputdate_seconds = strtotime($inputdate);

$time_diff = $dbdate_seconds - $inputdate_seconds;

//you will get the time difference in seconds, divide by 60 to make it minutes

or you can use the mysql TIMEDIFF

$query = select TIMEDIFF(field_name, '$input_date') from tbl_name where condition

Saturday, March 28, 2009

Expresso Best Way to Learn Regular Expression

Expresso is a free tool where you can master the art of writing complex regular expressions in no time. You also got a very good tutorial within the software to get started on regular expressions.
It also contain regular expression library to assist you in common problems.

http://www.ultrapico.com/Expresso.htm

Wednesday, March 25, 2009

Notice: Undefined index: (php)

Notice: Undefined index:
Sometimes you get this notice (This is not a error). lets see a example why you get this notice or warning.


<?php

error_reporting(E_ALL);

echo $name= $_POST["name"];
echo $number= $_POST["number"];

?>

<html>
<body>
<form name="form1" method="POST" action="">
<table border="0">
<tr>
<td>Name :</td>
<td> <input type="text" name="name" /></td>
</tr>
<tr>
<td>Tel: Number :</td>
<td> <input type="text" name="number" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="sub" value="Add" /></td>
</tr>
</table>
</form>
</body>
</html>



When you initially load this page you will get a notice like following.
Undefined index

This notice is shown because your php.ini file has enabled Notices to display or you may have a set error_reporting() function to E_ALL or to display notices.

The reason for the notice because when the page is load it search for the $_POST["name"] and $_POST["number"] which actually not available, $_POST indexes are set when you submit the form not when you just load the page.

Solutions:
1) you can fix the error reporting levels in php.ini or by error_reporting() function.

or

Change the code like this.


if(isset($_POST['sub']))
{
echo $name= $_POST["name"];
echo $number= $_POST["number"];
}


This will make the code run only when you submit the add button.

Sunday, March 22, 2009

How to change Mysql database storage engine

The default Mysql database storage engine is MyISAM. But if you want to implement foreign key constraints you should have the InnoDB storage engine. Lets see how we can change it. I will use the phpMyAdmin to do the operation.

change Mysql database storage engine 1

Select the table you want and press the "Operations" tab.

change Mysql database storage engine 2


change Mysql database storage engine 3

Now select a Storage Engine you like from the drop down menu and press "Go" button.

change Mysql database storage engine 4

Thursday, March 19, 2009

Find JavaScript Errors Easily

If you facing a hell of a time finding JavaScript errors you can use Firefox error console to get descriptive JavaScript errors. There are tools like Firebug, but error console comes built in Firefox so no need to worry about install. You find CSS errors also.

Goto tools -> error console

Firefox error console

Firefox error console 2

Monday, March 16, 2009

ServerSide JavaScript will be popular like php

In the near future ServerSide JavaScript (SSJS) will be popular like php. Eventhough ServerSide JavaScript (SSJS) has been around for sometime it never got wide publicity. Been a object oriented and a simple scripting language in nature it will be pretty easy to write dynamic code using (SSJS). I first heard about ServerSide JavaScript (SSJS) from Aptana Jaxer.

You can find a list of ServerSide JavaScript (SSJS) uses from this wiki article.
http://en.wikipedia.org/wiki/Server-side_JavaScript

Saturday, March 14, 2009

How to integrate a web editor (Rich Text Editor)

Lets see how to integrate TinyMCE into a web page

Goto http://tinymce.moxiecode.com and download the TinyMCE, select the main package to download.
TinyMCE Download

Now click on the example tab

TinyMCE Example tab

Now you can see the full featured example. You can find more example links also.
Click on the View Source.

TinyMCE full features

Click on the view source.

TinyMCE full source

Now copy and paste the code to your html file.

TinyMCE full source 2

Remember to correctly change the installation path

TinyMCE full source 3

Now you are done, Experiment with other examples also. If you need any help you can get my email from the profile.