Archive for » 2010 «

Tuesday, May 25th, 2010 | Author: admin

You don’t like to show your users a  standard and simple http error pages. OK Then let’s see how to manage to send the users to a different page, and create your custom error pages.

  1. In httpd.conf file,
    <Directory /var/www/>
    AllowOverride None
    Order allow,deny
    allow from all
    </Directory>

    to

    <Directory /var/www/>
    AllowOverride All
    Order allow,deny
    allow from all
    </Directory>

  2. Create .htaccess file, unless you do have one. It’s very simple to create a .htaccess file. Open some text editor and save the blank file name as .htaccess. Do not use any extension for the file name, just .htaccess. And don’t forget to put a dot before the file name.
    Write the page url in it, where you will redirect the user to:
    ErrorDocument 404 /404page.html
    or you can just give a message:
    ErrorDocument 404 “The page you are looking is no longer exists.”
  3. Create a html file with the name you given in the .htaccess. So for our example we will create 404page.html in root directory.
  4. Call a page, that does not in your root directory.

! And don’t forget to restart your apache server, after you do some changes in apache’s configuration file httpd.conf.

You can extend this example for any other http errors. Use just one .htaccess file per directory.

Category: About  | Leave a Comment
Friday, May 21st, 2010 | Author: admin

You have two date fields, one is for start date and another one is for end date.  You want to compare and ensure that date fields are in the correct order, like start date is before end date and other way around.

HTML Code:

<html>
<head>
</head>
<body>
<div>
Start Date :<input type=”text” name=”str_date” id=”str_date” size=”10″ value=”" onchange=”controlDate(this.id, ‘end_date’);” />
End Date :<input type=”text” name=”end_date” id=”end_date” size=”10″ value=”" onchange=”controlDate(this.id, ’str_date’);” />
</div>
</body>
</html>

You see, we add onchange javascript function to fields. And add below javascript code in the head of your page.

Javascript Code:

<script>
function controlDate(objId, dateId){
str_first_date = document.getElementById(objId).value;
str_second_date = document.getElementById(dateId).value;
first_date = conv_to_date(str_first_date);
second_date = conv_to_date(str_second_date);
if(objId == “str_date” && second_date != “”)
{
if(first_date > second_date)
{
alert(”Start date must be before end date!”);
document.getElementById(objId).value = “”;
return false;
}

}
if(objId == “end_date” && second_date != “”)
{
if(first_date < second_date)
{
alert(”End date must be after start date!”);
document.getElementById(objId).value = “”;
return false;
}

}
}

function conv_to_date(date_val)
{

var startYear = parseInt(date_val.substr(6,4), 10);
var startMonth = parseInt(date_val.substr(3,2), 10) - 1; // as per Residuum’s comment
var startDay = parseInt(date_val.substr(0,2), 10);
var dt = new Date(startYear, startMonth, startDay);
return dt;
}
</script>

Category: About  | Leave a Comment
Monday, May 03rd, 2010 | Author: admin

If you’re using templates in your project, you may want to use one template more than once. But what if you want to show some elements in one programme and hide these elements in second one. You constantly, write your ordinary two line of javascript code in the head of your html code. That’s where the problem occurs.

For example, you write the code below and run it in your browser,

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>
<head>
<meta http-equiv=”content-type” content=”text/html; charset=windows-1250″>
<title></title>
<script>
var e = document.getElementById(’mydiv’);
e.style.display = ‘none’;
</script>
</head>

<body>
<div id=”mydiv”>
Hello, How are you today?
</div>
</body>
</html>

Then you will get an javascript error: e is null. Because you can’t change the style of an element with javascript before the element is loaded in your page. But if you’re stubborn like me, you can write your javascript code end of your page.

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>
<head>
<meta http-equiv=”content-type” content=”text/html; charset=windows-1250″>
<title></title>

</head>
<body>
<div id=”mydiv”>
Hello, How are you today?
</div>
</body>
</html>
<script>
var e = document.getElementById(’mydiv’);
e.style.display = ‘none’;
</script>

I tested the code above, in IE6 and FF.

Category: About  | Leave a Comment
Thursday, April 22nd, 2010 | Author: admin

I’ve faced with this error when I tried to join one table with two different tables, in oracle 8i. Someone told me that this is imposibble to overcome and I should write some function and call the function in select statement. I insisted to solve the problem in one query because I wanted to believe that this should be done in Oracle somehow.  Moral of a fable, I found the solution in Ask Tom ( http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:3681127952930 ) and I want to share it.

I’m using the same example,

Query that’s giving the error:

SELECT
TIME_DIM.MONTH,
CUSTOMER_DIM.CUSTOMER_NAME,
SUM(SALES_FACTS.HOURS)
FROM
TIME_DIM,
CUSTOMER_DIM,
SALES_FACTS
WHERE
( SALES_FACTS.CUSTOMER_FK(+)=CUSTOMER_DIM.CUSTOMER_PK )
AND ( TIME_DIM.TIME_PK=SALES_FACTS.TIME_FK(+) )
GROUP BY
TIME_DIM.DAY,
CUSTOMER_DIM.CUSTOMER_NAME

Correct query is:

select ...
  from ( select * from time_dim, customer_dim ) A,
       sales_fact
 where a.customer_pk = sales_fact.customer_fk(+)
   and a.time_pk = sales_fact.time_fk(+)
 group by a.day, a.customer_name
Category: About  | Leave a Comment