Archive

Archive for the ‘Programming’ Category

Make javascript functions load last

November 6, 2009 Leave a comment

Perhaps there’ll be a time when you need your javascript function to load last inside a page. Simply put the javascript code before the tag of your page. Done :)!

For example:

alert(“This alert is displayed when everything else has been loaded!”);

//calls an ajax command, non ajax-commands works too
new Ajax.Updater(‘droparea’, ‘my-cart.php’, { method:’post’, parameters: { action: ‘display’}});

p/s: Take note that javascript functions won’t be loaded unless you explicitly calls it first

for example:

//The script below won’t be called

function hoyoyo(){
alert(“This alert is displayed when everything else has been loaded!”);
}

So just add a caller to the function to make it work


hoyoyo(); //calls the function below
function hoyoyo(){
alert(“This alert is displayed when everything else has been loaded!”);
}

Categories: JavaScript, Programming Tags:

Php copy .. failed to open stream: Permission denied in …

November 6, 2009 1 comment

Ever faced this problem when you’re trying to copy files using php? Well, as the error above said, you’re having a permission problem to access the source and/or destination file. I’ll describe two possible ways to overcome this problem:

1)If this problem happened on your local pc, you’ll just have to right click on the folder where the file resides, click Properties, and make sure the Read Only Attributes is not checked. Try running the code again.
2)If this problem happened on your internet(hosting) server, you’ll have to set the permission of the folder. If you’re using CPanel, go to File Manager, and browse to the parent directory of the folder, check (tick) the folder name, and click on the ‘Change Permissions’ button. Try enabling the folder’s Read, Write, and Execute for World and Group. Try running the code again.

For security reasons, after you’re sure that the code works, don’t forgot to tweak the permission settings so that only the minimal permission is granted. Sure you don’t want anyone out there to overwrite your files, don’t you?

Hope this post helps somebody out there!

Categories: PHP, Programming Tags: