Archive for the ‘What I have learned today’ Category

Importing large databases on Wamp5 PHPmyAdmin, how?

Tuesday, August 24th, 2010

Have a database bigger than 2MB? want to import them somewhere else? but you cant and PHPmyAdmin just gave you the dead end message below?

No data was received to import. Either no file name was submitted, or the file size exceeded the maximum size permitted by your PHP configuration. See FAQ 1.16.

Have no fear, there’s a solution:

Look for the php.ini file -> c:/wamp/www/apache2/bin/php.ini

Then change the following lines:

post_max_size = 8M
upload_max_filesize = 2M
max_execution_time = 30
max_input_time = 60
memory_limit = 8M

To these new values:

post_max_size = 100M
upload_max_filesize = 100M
max_execution_time = 5000
max_input_time = 5000
memory_limit = 100M

Then restart wamp5 and retry importing…

Happy coding :P

How to set Webserver Directory Index via .htaccess

Thursday, August 19th, 2010

What’s a webserver directory index anyway?

When an HTTP client (generally a Web browser) requests a URL that points to a directory structure instead of an actual Web page within the directory, the Web server will generally serve a general page, which is often referred to as a main or “index” page.

Most often index.html or index.php are used by developers, but we can set it to any file we want to with the help of .htaccess

on your .htaccess file write:

DirectoryIndex home.html

Above code is just telling that I want the file home.html be by default index page.

but you can also do this:

DirectoryIndex home.html index.html index.php

Above is telling the server that to use home.html as my default index page and if not use index.html else use index.php and so on…

So that’s it, fairly easy…

:)

Youtube embed code to pass w3c HTML validation? yes there’s a solution, see here!

Saturday, July 17th, 2010

For those who scour the net for a simple solution for a problem called “Make my YouTube embed code pass w3c HTML validation“, your in the PERFECT place, because what you’re about to read is not only simple, but the perfect solution!

Very confident me will now show you how its done :)

The usual Youtube embed code(do not pass w3c HTML validation)
NOTE: where ($vid) is your Youtube video ID

<object width="430" height="347">
<param name="movie" value="http://www.youtube.com/v/($vid)&amp;hl=en_US&amp;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/($vid)&amp;hl=en_US&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="430" height="347"></embed>
</object>

Ok you see, when using this code to display video, it will never pass validation but instead will render validation error such as “there is no attribute allowfullscreen”, “width” among others.

But with the code below, you can perfectly validate your Youtube pages :) see below and test it yourself.

NOTE: ($vid) is = to your Youtube video ID, for example http://www.youtube.com/v/RHzC7YOxkVY&hl=en_US&fs=1 the emphasized letters is your Youtube ID, So now presenting the code…

<object type="application/x-shockwave-flash" width="430" height="347" data="http://www.youtube.com/v/($vid)">
<param name="movie" value="http://www.youtube.com/v/($vid)" /></object>

Oh my, yes its much shorter, and its better!!! :D

Javascript concatenates instead of adding two form values? There’s an easy solution: parseInt() Javascript function

Thursday, July 1st, 2010

Javascript concatenates instead of adding two form values?

Ok, lets test this :)

SEE DEMO

<form id="form2" name="form2" method="post" action="#" onsubmit="document.getElementById('total2').value=parseInt(document.getElementById('field12').value)+parseInt(document.getElementById('field22').value); return false;">
  <p>
    <input type="text" name="field12" id="field12" />
  </p>
  <p>
    <input type="text" name="field22" id="field22" />
  </p>
  <p>
    <input type="submit" name="button" id="button" value="Add" />
  = 
  <input name="total2" type="text" id="total2" size="10" />
  </p>
</form>

True enough treat form values as string, so concatenates.

So, what should we do to make Javascript add those form values?

We can use Javascript function called parseInt().

The parseInt() function parses a string and returns an integer.

Ex: form.field2.value+form.field2.value (this will only concatenate)

SEE DEMO

<form id="form2" name="form2" method="post" action="#" onsubmit="document.getElementById('total2').value=parseInt(document.getElementById('field12').value)+parseInt(document.getElementById('field22').value); return false;">
  <p>
    <input type="text" name="field12" id="field12" />
  </p>
  <p>
    <input type="text" name="field22" id="field22" />
  </p>
  <p>
    <input type="submit" name="button" id="button" value="Add" />
  = 
  <input name="total2" type="text" id="total2" size="10" />
  </p>
</form>

Thats it! that should add two form values perfectly :) feel free to post any question and or comments thanks.

How to customize Magento’s currency symbol?

Tuesday, June 22nd, 2010

Editing Magento’s default currency symbol is relatively easy and can be done via admin.

But what if you wanted to display “USD” instead of “$”?

This too is easy enough for most of us-if you know where to look at! :)

Ok ok, to edit or customize default currency symbol look into;

MAGENTO_ROOT/lib/Zend/Locale/Data/

Look for you locale, in most cases en.xml (which is english), download and open it in your favorite editor, replace below code

<currency type="USD">
    <displayName>US Dollar</displayName>
    <displayName count="one">US dollar</displayName>
    <displayName count="other">US dollars</displayName>
    <symbol>$</symbol>
</currency>

With this code:

<currency type="USD">
    <displayName>US Dollar</displayName>
    <displayName count="one">US dollar</displayName>
    <displayName count="other">US dollars</displayName>
    <symbol>USD</symbol>
</currency>

I think you already noticed what we omit and replace on the code :) , easy enough, saved it and upload it to your server.

To make your life even more easier here’s a tip: you can find this line of code around line 3800 in en.xml

GOGOGO :)