Tuesday, December 30, 2008

Why sometimes Mysql Update does not work with php mysql_affected_rows()

Sometimes when you write a mysql update query it does not work properly with mysql_affected_rows()
You try to look for a syntax error, try to get the error from mysql_error() yet no error pops up. you just cannot see whats wrong with your mysql update query.

From my experience this could happen because your new updating values are same as the old values, mysql will not update that row, hence mysql_affected_rows() will not work because no rows were affected.

www.php.net/mysql_affected_rows - look at return values

Get custom programming done at GetAFreelancer.com!

Friday, December 26, 2008

What is Cannot modify header information in php

Warning: Cannot modify header information - headers already sent by ......
This error is a shocker for a new php programmer. when you do some basic redirection and you bump into this error you are left clueless.

In the simplest form this happens when you output somthing into the screen before using the header() function.


<?php

echo 'hello and I doomed the header';

header("Location: login.php");

?>


above code will get that error because you have already output something to the screen.(If you are testing in your local machine this error is not shown)

This error is also generated by a unsuspecting white space. This could be a white space from a include file before the header() function.

Get custom programming done at GetAFreelancer.com!

Sunday, December 21, 2008

How to make a HTML input Text Box transparent

When you have a input text box on top of a image, you usually need to make the textbox transparent so that users can see the image right through the input text box.
This can be done by adding the following style code
style="background-color:transparent;"
This can be added to any input html control.

<input type="text" name="name" style="background-color:transparent;" />


Get custom programming done at GetAFreelancer.com!

Wednesday, December 17, 2008

How to find floor or ceiling value of a number using php

Following code will show you how to find floor and ceiling values of a floating number. To find floor you can use the php function floor() and ceil() to find ceiling value.


<?php

//examples of floor()
echo floor(7.2); // 7
echo '<br>';
echo floor(7.9); // 7

echo '<br><br>';

echo ceil(7.2); // 8
echo '<br>';
echo ceil(7.9); // 8

?>


Get custom programming done at GetAFreelancer.com!

Monday, December 15, 2008

How to find the power of a number (Exponential) using php

Following code will show you how to find the power of a number using php.
The function used to do this is pow() function.
pow(base, exponent)


<?php

//first parameter is the base
//second parameter is the exponent

echo pow(2, 2); // 4
echo pow(2, 3); // 8
echo pow(3, 2); // 9

?>



Get custom programming done at GetAFreelancer.com!

Saturday, December 13, 2008

How to list all tables in a mysql database using php

Following code will show you how to get all the table names inside a given mysql database. to do this you only need know about the mysql query "SHOW TABLES".
following example show you how to retrieve query the result using php.


<?php

//set your DB connection
mysql_connect('localhost', 'root', '');
//select your DB
mysql_select_db('test');

$query = "SHOW TABLES";
$result = mysql_query($query);

while($data = mysql_fetch_array($result))
{
echo $data[0];
echo '<br />';
}

?>


Get custom programming done at GetAFreelancer.com!

Thursday, December 11, 2008

How can I add html tags inside my php code

Can I add html tags inside my php code? Yes almost any html tag.
To use html tags inside php you can use echo to print them.
Look at the following code.


<html>
<head>
<title>Untitled Document</title>
</head>

<body>

<?php

echo '<strong>This is bold letters</strong>';

echo '<h1>This is heading letters</h1>';

echo '<div style="border: solid #000000;">
This is inside a div tag</div>';

?>

</body>
</html>


Like above example you can use any html tags.

Get custom programming done at GetAFreelancer.com!

Friday, December 5, 2008

How to find the table structure of a mysql table in php

You can use sql command describe to get the table structure of a mysql table.
It will return six information for each table attribute (column).
Field, Type, Null, Key, Default, Extra



<?php

//include your DB connection

$query = "describe your_table_name";
$result = mysql_query($query);

//loop through each table column attribute
while($data = mysql_fetch_array($result))
{
echo $data['Field'].', '; //field name
echo $data['Type'].', ';//feild type
echo $data['Null'].', ';// null or not
echo $data['Key'].', ';//primary key or not
echo $data['Default'].', ';//default value
echo $data['Extra'];// like auto increment
echo '<br />';
}

?>


Get custom programming done at GetAFreelancer.com!

Wednesday, December 3, 2008

How to check if a given value is numeric (integer) using php

Following code will show you how to validate a variable to see if its a numeric integetr or a string. you can use is_numeric() and is_int() functions to validate this. Use
is_numeric() when validating form data, which will always be strings.

is_int() will check if the variable type is integer. so form data will always be false.

is_numeric() will check if the variable contain all numbers, use this function to validate form data.


<?php

$num1 = 48;
$num2 = '48';
$num3 = 'hello';

if(is_int($num1))
{
echo 'This is integer';
}
else
{
echo 'Not integer';
}

//check for above other $num2 and $num3 variables.

/*
USE is_numeric() IF YOU ARE VALIDATING FORM DATA
INSTEAD OF is_int()

*/

?>


Get custom programming done at GetAFreelancer.com!

Tuesday, December 2, 2008

What is the difference between mysql_fetch_array() and mysql_fetch_assoc() - which is faster?

Lets see an example.

Lets think we have a table with following fields,
id
name
age

Now when you use mysql_fetch_array() it will return both numeric array and an associative array.


while($data = mysql_fetch_array($result))
{
//will return

$id = $data[0];
$id = $data['id'];

$name = $data[1];
$name = $data['name'];

$age = $data[2];
$age = $data['age'];

}


when you use mysql_fetch_assoc() it will return only an associative array.


while($data = mysql_fetch_assoc($result))
{
// will return

$id = $data['id'];
$name = $data['name'];
$age = $data['age'];

}



So mysql_fetch_assoc() is comparatively faster because its only return a associative array.

Get Free Sinhala IT Learning Videos Kuppiya.com


Get custom programming done at GetAFreelancer.com!

Monday, December 1, 2008

Get content in 2 fields with the same field name in two mysql tables using php

Following code will help you understand how to get values from 2 mysql tables where there are same field names in each table.
This problem usually occurs when you join two tables together.

Example: lets take two tables

Table1
id
s_name
age


Table2
id
p_name
age


In above two tables there is a id field in both.

$query = "select * from Table1, Table2"

The thing in here is not to use mysql_fetch_assoc(), use mysql_fetch_array()

$result = mysql_query($query);
while($data = mysql_fetch_array($result))
{
when you loop through to get the values just remember it will be formatted like following.

}

Table1 id => $data[0]
Table1 s_name = > $data[1]
Table1 age => $data[2]

Table2 id = > $data[3]
Table2 p_name => $data[4]
Table2 age = > $data[5]


Get Free Sinhala IT Learning Videos Kuppiya.com


Get custom programming done at GetAFreelancer.com!

Sunday, November 30, 2008

undefined method 'scaffold' - Ruby on Rails error

When I first got the error undefined method 'scaffold' I was so frustrated because I was new to Ruby on Rails and was following a tutorial. After some search on the net I found out that method scaffold is no longer supported in Rails 2.0 and above.
Tutorials out there in the net really need to be updated because newcomers are stuck when they get errors in the tutorial it self.

Get Free Sinhala IT Learning Videos Kuppiya.com


Get custom programming done at GetAFreelancer.com!

Saturday, November 29, 2008

InstantRails 2.0 - Default Database is SQLite3, How to change into mysql

InstantRails 2.0 or higher versions comes with the SQLite3 as the default database,
So a command like this rails my_app will take SQLite3 as the default database for the Rails application.

To use mysql try the following command:
rails -d mysql my_app

extra parameter -d will define database

Get Free Sinhala IT Learning Videos Kuppiya.com


Get custom programming done at GetAFreelancer.com!

Friday, November 28, 2008

Ruby on Rails quick guide with InstantRails

Lets get started quickly on Ruby on Rails basics with InstantRails, First we'll see how to add a new Rails application using InstantRails ruby console.

1) Start up your InstantRails.

2) Right Click the InstantRails system tray icon and goto Rails Applications -> Open Ruby Console Window

3)you will be in rails_apps folder(default) in the command line.

4)type rails my_new_site on the command line

This will create a new my_new_site rails application inside the rails_apps folder, all the files needed will be created for you as well, just navigate to your rails_apps folder and view newly created my_new_site folder.



5) now lets start our web server to run our newly created RoR application using the command line

6) type cd my_new_site (change directory to my_new_site)

7) type ruby script\server
Now your web server is started and you can run your new application.




8) open a browser and type http://localhost:3000/ in the navigation bar.



To learn how to install InstantRails click here

Get custom programming done at GetAFreelancer.com!

Thursday, November 27, 2008

How to install Ruby on Rails - Instant Rails - All in one Package

If you are going to learn Ruby on Rails (RoR), Instant rails will make your RoR installation much more easier, like WAMP Server for php, Instant Rails is all in one package containing Ruby, Rails, Apache, and MySQL. All the things have been configured for you that you only need download and unzip the Instant Rail folder to your C: drive.

1) Download Instant Rails from here Download the latest zip file (InstantRails-2.0-win.zip when I write this)

2)Unzip the Instant Rail into C:\InstantRails

3)Double click the InstantRails.exe (Icon with big red I)

4)Now InstantRails system tray icon will run on you Taskbar

5)To see if all went well, Right Click the InstantRails system tray icon and goto Rails Applications -> Open Ruby Console Window



6)Type ruby --version in the opened command line window, then you will get the installed ruby version.

OK that's it. In my next blog post I will cover some basics when working with InstantRails for your RoR development.

Get Free Sinhala IT Learning Videos Kuppiya.com


Get custom programming done at GetAFreelancer.com!

Wednesday, November 26, 2008

How to get the Square root of a numeric value using php - sqrt()

Following code will show you how to get the Square root of a given numeric value.


<?php

echo sqrt(4); // 2

echo sqrt(12); // 3.4641016151378

echo sqrt(16); // 4

echo sqrt(17); // 4.1231056256177

?>


Get Free Sinhala IT Learning Videos Kuppiya.com


Get custom programming done at GetAFreelancer.com!

Tuesday, November 25, 2008

How to round a floating point number in php - round()

Following code will show you several examples on how to round a floating numeric value as you like.


<?php

echo round(10.8); // 11
echo '<br />';
echo round(10.4); // 10
echo '<br />';

/*you can also set the number of precision,
or in other words number of decimal digits
you like to round the floating number
*/

echo round(10.837, 2); // 10.84
echo '<br />';
echo round(10.435767, 4); // 10.4358
echo '<br />';

?>


Get Free Sinhala IT Learning Videos Kuppiya.com


Get custom programming done at GetAFreelancer.com!

Monday, November 24, 2008

How to create a dynamic pdf file using php - FPDF fpdf.org

If you need to create dynamic or on the fly pdf files using php, usually we use PDFlib library. but PDFlib library sometimes not available in all hosting packages.
FPDF is a good alternative for PDFlib library, FPDF is a Free php class that you can easily include in you php code, really easy and simple to use FPDF is my choice when creating pdf files on the fly.

www.fpdf.org

Get Free Sinhala IT Learning Videos Kuppiya.com


Get custom programming done at GetAFreelancer.com!

Thursday, November 20, 2008

How to split a string using javascript - split() method

Following code will show you how to split a string using a given separator.



<head>

<script type="text/javascript">

var my_string = "Hello My Name Is Kusal";
var split_var = my_string.split(" "); //separate by space

alert(split_var[0]); //Hello
alert(split_var[1]); //My
alert(split_var[4]); //Kusal

</script>

</head>



Get Free Sinhala IT Learning Videos Kuppiya.com


Get custom programming done at GetAFreelancer.com!

Friday, November 14, 2008

How to add RGB color values for select box or a DIV tag

Following code will show you two exapmles on how to add RGB color values to a Select DropDown Box and a DIV tag.


<body>

<select name="colors">
<option>Select</option>
<option style="background-color:rgb(200,250,300);">Color 1</option>
<option style="background-color:rgb(100,89,200);">Color 2</option>
<option style="background-color:rgb(65,89,50);">Color 2</option>

</select>

<br /><br />

<div style="background-color:rgb(200,100,100);">Hello</div>

</body>


Get Free Sinhala IT Learning Videos Kuppiya.com


Get custom programming done at GetAFreelancer.com!

Monday, November 10, 2008

How to search/scan files inside a directory using php - scandir()

Lets see how we can scan or search files inside a directory using php. You can use scandir() for this matter. scandir() will go through the given directory and return all the files in an array.


<?php

$dir_path = 'kusal/test'; //directory path
$list_files = scandir($dir_path);

//dumping the array
//hope you know how to access an array
echo '<pre>'; //html <pre> tags will format the output
print_r($list_files);
echo '</pre>';

/*
Output look like this

Array
(
[0] => .
[1] => ..
[2] => TextDocument.txt
[3] => kuppiya.doc
[4] => lion.ppt
[5] => test.as
)

*/

?>



Get Free Sinhala IT Learning Videos Kuppiya.com


Get custom programming done at GetAFreelancer.com!

Friday, November 7, 2008

How to delete a directory using php - rmdir()

Lets see how can we delete a folder using php.
You can use rmdir() function to do this task, before using this function you should remember that you can only delete empty folders


<?php

$path = 'path to directory'

//First Check if deleting a directory
if(is_dir($path))
{
//remove directory
if(rmdir($path))
{
echo 'Deleted';
}
else
{
echo 'error';
}
}
else
{
echo 'Not a directory';
}
?>


Get Free Sinhala IT Learning Videos Kuppiya.com

 Subscribe To My Blog

Sunday, November 2, 2008

How to use getElementById in JavaScript

Following codes will show you how easy it is to use JavaScript getElementById to manipulate HTML elements.

Example 1 - On mouse over the text will be red, on mouse out it will be black again.


<html>
<head>

<script type="text/javascript">

function chng_color()
{
document.getElementById('my_div').style.color = 'red';
}

function normal_color()
{
document.getElementById('my_div').style.color = 'black';
}

</script>

</head>

<body>

<div id="my_div" onmouseover="chng_color()" onMouseOut="normal_color()">

This is the first example!!!

</div>

</body>
</html>


Example 2 - Get entered text of a text box and display it on a JavaScript alert box.


<html>
<head>

<script type="text/javascript">

function alrt_text()
{
var entered_text = document.getElementById('my_text_box').value;
alert(entered_text);
}

</script>

</head>

<body>

Your Text:
<input type="text" name="my_text_box" id="my_text_box" onBlur="alrt_text()" />

</body>
</html>


*Always remeber to give a id name for your HTML elements before using getElementById()

Get Free Sinhala IT Learning Videos Kuppiya.com

Subscribe To My Blog

Monday, October 27, 2008

How to convert a string into a lowercase letters (simple letters) using php

Following code will show you how to convert a string of letters into lowercase(simple) using php strtolower() function.


<?php

$my_string = "This STRING has UPPERCASE letters";
$my_string = strtolower($my_string);
echo $my_string;

//Output: this string has uppercase letters

?>



Get Free Sinhala IT Learning Videos Kuppiya.com

 Subscribe To My Blog

Sunday, October 19, 2008

How to validate a date to see if its a correct date format using php

You have function called checkdate() where you can validate a input date is actually a correct date format. checkdate() will validate Gregorian date, so we need to properly give the parameters for the checkdate() function.
checkdate($month, $day, $year) - will return true or false


<?php

//checkdate($month, $day, $year) - format

$month = 10;
$day = 12;
$year = 2008;

echo 'Valid Date Example: ';

if(checkdate($month, $day, $year))
{
echo 'Date is correct';
}
else
{
echo 'Date is incorrect';
}

echo '<br /><br />';
echo 'Invalid Date Example: ';

//Invalid date
$month = 14; // month is wrong
$day = 12;
$year = 2008;

if(checkdate($month, $day, $year))
{
echo 'Date is correct';
}
else
{
echo 'Date is incorrect';
}

?>


Get Free Sinhala IT Learning Videos Kuppiya.com

 Subscribe To My Blog

Wednesday, October 15, 2008

How to join array elements together using php - implode()

Lets see how we can join elements in a array to a comma separated String (You can use any separator you want with implode().)
simply use implode and you are done


<?php

$array_items = array('item1', 'item2', 'item3');
$string_with_comma = implode(",", $array_items);

echo $string_with_comma; // item1,item2,item13

?>


Get Free Sinhala IT Learning Videos Kuppiya.com

 Subscribe To My Blog

Sunday, October 12, 2008

How to find the array key for a given value using php - array_search()

You can use array_search() for searching a value within a given array.
You can search a given value in an array and return the relevant key using array_search()


<?php
$array = array(0 => 'Tom', 1 => 'Kusal', 2 => 'Jerry', 3 => 'Jhonny');

$key = array_search('Tom', $array);
echo $key; // $key = 0;

/* sample
$key = array_search('Kusal', $array); // $key = 1;
$key = array_search('Jerry', $array); // $key = 2;
$key = array_search('Jhonny', $array); // $key = 3;
sample */


?>


Get Free Sinhala IT Learning Videos Kuppiya.com

Subscribe To My Blog

Wednesday, September 24, 2008

How to check if a given value exists in an array using php

If you want to check if a given value exists in a php array variable, you can simply use the php in_array() function. This function will return true if searched value exists else will return false.


<?php

$names = array("Bill", "Kusal", "Rex", "Jhon");

if(in_array("Kusal", $names))
{
echo "Kusal is here";
}
else
{
echo 'Not Found';
}

?>



Get Free Sinhala IT Learning Videos Kuppiya.com

 Subscribe To My Blog

Monday, September 22, 2008

How to make a string all Uppercase using php - Make a word capital

Lets see how we can convert a given string into all uppercase letters using php
We can use the strtoupper() function to do the trick for us


<?php
$word = "we Love php";
$word = strtoupper($word);
echo $word; //WE LOVE PHP
?>





Get custom programming done at GetAFreelancer.com!

Friday, September 19, 2008

How to add date and time using php - mktime()

When you need to add time or add date, you don't need to explode your time string and add time or date separately for each part, you can simply use php's powerful mktime() function to do all the work.


<?php

echo 'Original Date/Time <br />';

//mktime(hour,minute,second,month,day,year)

echo date("h:i:s d-m-Y", mktime(10, 15, 20, 8, 20, 2008));
//10:15:20 20-08-2008

echo '<br /><br />';

echo 'Date/Time Added by 1';
echo '<br />';

echo date("h:i:s d-m-Y", mktime(10+1, 15+1, 20+1, 8+1, 20+1,2008+1));
//11:16:21 21-09-2009

?>



Get Free Sinhala IT Learning Videos Kuppiya.com

Subscribe To My Blog

Friday, September 12, 2008

How to change background color in a DIV tag on onmouseover

As a web developer it's essential that you are comfortable with CSS styles, you maybe a php,.net,ruby on rails developer but it's always good to have some style tricks in your pocket so that you don't need to find a web designer to do it for you. following code is a simple way to change the color of the background of a DIV tag on mouse over event.


<div onmouseover="this.style.background='green';"
onmouseout="this.style.background='white';">
kuppiya.com
</div>


Get Free Sinhala IT Learning Videos Kuppiya.com

Get custom programming done at GetAFreelancer.com!

Wednesday, September 10, 2008

How to get current URL using JavaScript

Simplest way to get the current browser URL using JavaScript is to use window.location.href
Look at the following code,


<script type="text/javascript">

var url = window.location.href;

document.write(url);

</script>


Get Free Sinhala IT Learning Videos Kuppiya.com

 Subscribe To My Blog

Sunday, September 7, 2008

How to reload parent window from a iframe

Lets see how we can reload or refresh parent page from a iframe. This is pretty simple with small piece of JavaScript - top.location.href
Look at the following code it has two pages.

frame.htm - parent


<HTML>
<HEAD>
<TITLE>Parent window</TITLE>
</HEAD>
<BODY>

<table border="1">
<tr>
<td>This is main</td>
<td><iframe src ="frame2.htm" width="100%">
</iframe></td>
</tr>
</table>

</BODY>
</HTML>



frame2.htm


<HTML>
<HEAD>
<TITLE>New Document</TITLE>
</HEAD>
<BODY>

<div onClick="top.location.href='frame.php'">
Click here to reload parent page</div>

</BODY>
</HTML>


Get Free Sinhala IT Learning Videos Kuppiya.com



Get custom programming done at GetAFreelancer.com!

Wednesday, September 3, 2008

How to change time zone using php - set default timezone for php

Surely when you develop a site, you need to change current server timezone to a different timezone for client requirements.
You can use date_default_timezone_set() to set default timezone for a given script. You can also edit the php.ini to change the timezone for all projects.

You can find list of supported timezones HERE for the above function

<?php

//before use of date_default_timezone_set

echo date("d-m-Y h:i:s A");

echo '<br /><br />';

//set to US central time
date_default_timezone_set('US/Central');

echo date("d-m-Y h:i:s A");

?>


Get Free Sinhala IT Learning Videos Kuppiya.com

Freelance Jobs

Friday, August 29, 2008

SPAW Editor - Free web based in-browser WYSIWYG editor for php and .net

SPAW Editor is a Free web based in-browser WYSIWYG editor.
Very good features and fully customizable and has support for both php and .net
very easy and simple to integrate into the site.
This tool is great to build a Content Management System(CMS) for you site.



SPAW Editor


Get custom programming done at GetAFreelancer.com!

Wednesday, August 27, 2008

How to convert Unix Timestamp to Mysql Timestamp - Time() to String using php

If you want to convert the Unix timestamp into a string like mysql timestamp you can take a look at following code. Unix timestamp is not human readable so there are situations where you need to convert it into a human readable form.


<?php

$time_now = time();

echo $time_now; //output example: 1219848654
echo '<br />';

$str_time = date('Y-m-d H:i:s', $time_now);

//look at php date function for more options

echo $str_time; // 2008-08-27 14:50:54

?>


Get Free Sinhala IT Learning Videos Kuppiya.com



Get custom programming done at GetAFreelancer.com!

Tuesday, August 26, 2008

how to get a specific row in a large result set in mysql using php

When you work with a large result set you may need to get a specific row from the result set. When in a such situation you can use mysql_result().


$result = mysql_query('SELECT * FROM tbl_name');
echo mysql_result($result, 5); // output 6th row


Get Free Sinhala IT Learning Videos Kuppiya.com

 Subscribe To My Blog

Sunday, August 24, 2008

How to remove first letter from a string using php - substr()

When you need to strip or remove the first letter from a string, the easiest way to do it is to use php substr(). you can use substr() for many purposes look at the php manual here

<?php

$my_text = '12345678';

echo substr($my_text, 1);  // 2345678

?>



Get custom programming done at GetAFreelancer.com!

Thursday, August 21, 2008

How to redirect a page using java script - window.location

when you need to redirect a web page using JavaScript you can easily use window.location to redirect a page to anther web page.
Check out the following code


<HEAD>
<SCRIPT language="JavaScript">
<!--
window.location="http://yourURL.com";
//-->
</SCRIPT>
</HEAD>



Get Free Sinhala IT Learning Videos Kuppiya.com

 Subscribe To My Blog

Wednesday, August 20, 2008

How to get current executing file in php

When you need to get the currently executing php script, you can use $_SERVER["SCRIPT_NAME"] to get the full path of the executing file, then you can easily explode the returned string and get the file name only.
Look at the code below


<?php

//get current executing page
//you get the full directory path
//ex: /test/path.php

$file_path = $_SERVER["SCRIPT_NAME"];

//so we expolde it into an array
$parts = Explode('/', $file_path);

//need to get the last element from array
$file_name = $parts[count($parts) - 1];

echo $file_name; //path.php

?>


Get Free Sinhala IT Learning Videos Kuppiya.com

 Subscribe To My Blog

Tuesday, August 19, 2008

How to get Max ID row from mysql table using php

Do you need to find the max id of a mysql table? check out the following code.
simply use the sql MAX function to find the max id.

<?php

mysql_connect("localhost","root","");
mysql_select_db(test);

$q = "select MAX(id) from tbl_name";
$result = mysql_query($q);
$data = mysql_fetch_array($result);

echo $data[0];

?>


Friday, August 15, 2008

How to check if a array key exists in php - array_key_exists()

when writing code using arrays you'll probably found stuck on a situation where you loose track of array keys in a associate array, or maybe its random that you don't know if its there or not.


if (array_key_exists('key_name', $search_array))
{
echo "array key found";
}


Get Free Sinhala IT Learning Videos Kuppiya.com


Get custom programming done at GetAFreelancer.com!

Thursday, August 14, 2008

How to open a PDF inside a php file - Restrict access to pdf files using php

Following code will show you how to open a pdf file inside a php file. This will allow you to restrict access to it. you can use some if else logic to control to display who see the pdf or who does not.


<?php

//you can get data from database in here
$user = 'some value';

if($user == 'some value')
{
$file = "test.pdf";
header('Content-type: application/pdf');
header("Content-Disposition: inline; filename=".$file);

//this line will make the file directly download
/* header("Content-Disposition: attachment; filename=".$file); */

header('Cache-control: private');
header('Expires: 0');
readfile($file);
}
else
{
echo 'you cannot access this file';
}
?>


Get Free Sinhala IT Learning Videos Kuppiya.com



Get custom programming done at GetAFreelancer.com!

Sunday, August 10, 2008

How Mysql TIME data type works with php

Lets see what is the format that is accepted by Mysql TIME data type.
Normal format: HH:MM:SS
Extended hour format: HHH:MM:SS - This is larger than 23 hours because its used to store time between two points.

It's better if you use above formats to store your time manually


INSERT INTO your_tbl VALUES ('14:26:05')



Get Free Sinhala IT Learning Videos Kuppiya.com

 Subscribe To My Blog

Friday, August 8, 2008