Saturday, May 12, 2007

Why does call me PayPal? ;@)

After purchasing some product from and paying with my PayPal account. decided that my name is PayPal ;) obviously it's some glitch.. but i find it funny.

Monday, December 4, 2006

Image uploading using AJAX

Well, i guess i'm feeling Hot today ;)
Two posts within 24 hours, wow... lol
Well, i've been working on a project and was looking for an existing Image uploader that uses AJAX, knowing in advanced that really it's impossible (except for FF) to use xmlHTTPRequest, i was looking for a solution that uses iFrame, while googling it, it wasn't hard to come up with Asynchronous image file upload without AJAX by Martin Konicek. So i went ahead and downloaded it. After setting it up the first time, i got real bugged that it supported only Jpeg, when you'd upload something otherwise, it will just show an X instead of the image, that is not acceptable when you are creating a system for a client. Unless you want to give him a "Do not do" list for your product.
So i started playing with the code, while reading through, found out some really annoying stuff and fixed it according to my ideology. Unfortunately while doing that i didn't know i will actually re-release the code, so i didn't comment out all the changes i've made, but the most major ones are:
Support for JPEG,GIF,WBMP and PNG. (All credit goes to Huda M Elmatsani which class i used to do the conversion 'i.e had to modify that script as well').
The script doesn't throw an error in FF saying that it can't work out the setTimeOut.
The script doesn't trying to read the uploaded file information when no file has been uploaded, and is not trying to upload a file when the uploaded file field is empty.
These are the major changes to the script. Again, all credit goes to the creators of the script, All i did is modified it to my needs and hopefully it will serve any of you too.
For the sake of it, i renamed the script to Asynchronous image file upload without AJAX + PLUS so people will be able to distinguish between the two.
The script can be downloaded in the following link. Unfortunately i had to upload it to Rapidshare, if any of you is willing to host it on their servers, i'll be very thankful.
Till next time....

Download File

Auto Resize div according to windows size.

Welcome back guys, This week i decided to share you with a small problem i've encountered this week and of course, the solution. Hopefully it will save you some time in case you'll get there too.
While developing a calendar based on AJAX, i had a div container that included all the Calendar's data.
Thus, the container was set as overflow: auto. The problem was, that i wanted the container to be with 100% width, and 100% height, however, percents didn't do the trick, so i thought what about width: auto? well, that did the trick on the width side, but on the height side i still had a problem.
After spending some time thinking about the problem, I decided to fold my sleeves, and get to work.
I wrote some code that manually alters the height of the container to fit the page size.
The code has been tested in FF 2.0 and IE 7.0.
So let's go through the solution.

Firstly, i borrowed couple classes and altered em' a little to get a reference to an object and the width,height of window (though i'm using only the height value).

function getObj(name){
if (document.getElementById){
this.obj = document.getElementById(name); = document.getElementById(name).style;
else if (document.all){
this.obj = document.all[name]; = document.all[name].style;

This class does a simple job, it gets an ID as the parameter, and contains a reference to it's obj and style.

function getWinSize(){
var iWidth = 0, iHeight = 0;

if (document.documentElement && document.documentElement.clientHeight){
iWidth = parseInt(window.innerWidth,10);
iHeight = parseInt(window.innerHeight,10);
else if (document.body){
iWidth = parseInt(document.body.offsetWidth,10);
iHeight = parseInt(document.body.offsetHeight,10);

return {width:iWidth, height:iHeight};

The above class contains the Height and Width of the viewable window.
Now that we've got the actual Height of the window, Let's adjust the size of our container to fit the page.
function resize_id(obj) {                           
var oContent = new getObj(obj);
var oWinSize = getWinSize();
if ((oWinSize.height - parseInt(oContent.obj.offsetTop,10))>0) = (oWinSize.height - parseInt(oContent.obj.offsetTop,10));

What the function is doing is rather simple. We create a reference to our container oContent. Then we get the size of the window and store it in oWinSize.
Now, we are setting the new size of our container to be the (Size of the window)-(The distance of our container from the top of the window) and the result is, our container will remain at the same starting point, however, will last until the bottom of the screen. Mission accomplished :)
Now that we have a function that resizes our container to stretch all over the screen, let's make sure we call it every time the window size changes.
we can either write
window.onresize = function() { resize_id('ID_of_Container'); } 
Or inside
<body onResize="resize_id('ID_of_Container');">

Where ID_of_Container is the ID of the container we are willing to be stretched out.

Well guys, Until next week....
Any comments are welcomed, also questions :)

Yours, Blond R.

Saturday, November 25, 2006

Set up IIS 7 w/ MySQL and PHP 5

Hey fellas, this is my first Blog Post.
In my posts i'll try to share with you some experiences i've had in the past week during my work as a web developer.

As all of us are talking about the new coming Windows Vista, I decided to dedicate my first post to guide you all on how to setup IIS 7 along with MySQL and PHP 5. Before entering the venture myself, I searched the internet for tutorials on how about to do that, however, the closest i got was to install IIS 7, PHP and MySQL, however, everywhere i looked the PHP didn't work with MySQL.

I decided to go on the ride anyways, hoping to get it to work, and fortunately, i did ;).
Here is how i was about doing that:

First step, IIS 7.

I have Windows Vista RTM 64bits, thus this guide will show all the steps required to set it up on Vista 64bits, however, i will try mention all the steps that 32bit users should accomplish instead.
In order to set IIS 7 up, please go to Start->Control Panel->Programs->Turn Windows features on or off.
see yellow mark on the picture below

Inside the window that popped up, Look in the list for Internet Information Services. and check the box next to it.

Under "Internet Information Services"->"Web Management Tools" check "ISAPI Extensions".

Click ok and wait for it to install IIS 7. When finished close the Control Panel window.

That's it, IIS 7 is all set, in order to confirm that, you can try to go to http://localhost in your favorite browser.

Next step: PHP 5.

Because i was using the 64bit edition of Vista, instead of downloading the regular distribution from i downloaded a 64bit version from, Please download the zip package, as of this time, the latest version is 5.2.0

People who are using the 32bit edition of Vista, please download the zip package from

Unzip the zip to your drive, i used C:\php. now inside C:\php you will find a file named php.ini-dist.

copy this file to c:\windows\ and rename it to php.ini (erase the -dist part).

Now open the php.ini in notepad.

Inside the file, look for the line ;extension=php_mysql.dll and delete the semi-color (;) from the beginning of the line.

Now save and close the file.

Next, let's copy the dll to the right place...

Go to c:\php\ext and copy the file php_mysql.dll. Now go to C:\Windows\System32 and paste the dll there.

When asked to, Click continue to gain Administrator privilege.

Now let's configure IIS to work with our PHP.

Go to start->run and start InetMgr.exe (IIS Manager).

Inside IIS Manager click on "Handler Mappings".

On the right side of the window, click on "Add Script Map..." (Yellow box in the pic below)

In the window that pops up, fill up the fields with these values:

"Request path:" *.php

"Executable:" C:\php\php5isapi.dll

"Name:" PHP

The window should look like this one when you are done.

Click "Ok", And when the "Add Script Map" dialog pops up, Click "Yes".

Ok, so we have PHP and IIS 7 working together, now it's time to add the last piece to the puzzle, MySQL.

Download MySQL, i used MySQL 5.1 located at:

32bit users, download the 32bit distribution, 64bit, download the 64bit one.

Once you downloaded the MySQL installer, 32bit users, all you have to do is go through the Installer steps (Click next,next next next) and you should be fine.

64bit users, you still got some little work, after installing the MySQL, i had a problem running the configuration wizard, in order to solve that problem, i used the following trick.

I downloaded the 32bit zip package (without installer), inside C:\Program Files\MySQL\MySQL Server 5.1\bin i renamed the file libmySQL.dll to libmySQL64.dll and copied the 32bit file into the directory instead. Then i ran the configuration wizard, and this time it worked.

After the configuration process was completed, delete the 32bit file from the directory and rename the file libmySQL64.dll back to libmySQL.dll.

That's it, you are all set with IIS 7+MySQL+PHP.

In order to make sure that everything is in order, create a file named test.php inside C:\inetpub\wwwroot\ and write inside

Then inside your favorite browser browse to http://localhost/test.php and you should see all the settings of your php installation, if you will scroll down, you should also see MySQL settings which will confirm that MySQL is indeed installed.

A fix for Sessions Issue: Vista seems to have a permission problem with php's session.

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct () in Unknown on line

In order to solve the issue, inside CMD as administrator (Right click on CMD.exe and "Run as administrator"). write these two commands:

icacls %windir%\serviceprofiles\networkservice\AppData\Local\Temp /grant Users:(CI)(S,WD,AD,X)

icacls %windir%\serviceprofiles\networkservice\AppData\Local\Temp /grant "CREATOR OWNER":(OI)(CI)(IO)(F)

Well, i hope that my first Post will assist at least some of you, any comments regarding my writing are welcome. And of course, if you have any questions or you are having any difficulties in the process, don't hesitate to comment and i promise to try and help with every comment.

Till the next time...