Importing large databases on Wamp5 PHPmyAdmin, how?

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

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…

:)

Joomla 404s redirect

August 5th, 2010

If you want to see the error page in theme design and don’t like redirecting to error page URL or duplicating HTML in the error page template, here is a way to apply your theme template to the error page.

First, put the following code in templates/system/error.php:

Dont forget to put it

    BEFORE THE DOC TYPE!

<?php 
if ($this->error->code == '404') {
    header('Location:www.domain.com/your-custom-error-page.html');
    exit();
} 
?>

Thats it!

Creating your own captcha images, security images on the fly

July 17th, 2010

Here’s the code im using for all of the websites and projects :)

 
<?php
session_start();
 
$strlength = rand(4,7);
 
for($i=1;$i<=$strlength;$i++){
$textornumber = rand(1,3);
 
if($textornumber == 1){
$captchastr .= chr(rand(49,57));
}
if($textornumber == 2){
$captchastr .= chr(rand(65,78));
}
if($textornumber == 3){
$captchastr .= chr(rand(80,90));
}
 
}
 
$randcolR = rand(100,230);
$randcolG = rand(100,230);
$randcolB = rand(100,230);
 
//initialize image $captcha is handle dimensions 200,50
$captcha = imageCreate(200,50);
 
$backcolor = imageColorAllocate($captcha, $randcolR, $randcolG, $randcolB);
 
$txtcolor = imageColorAllocate($captcha, ($randcolR - 20), ($randcolG - 20), ($randcolB - 20));
 
for($i=1;$i<=$strlength;$i++){
 
$clockorcounter = rand(1,2);
 
if ($clockorcounter == 1){
$rotangle = rand(0,45);
}
if ($clockorcounter == 2){
$rotangle = rand(315,360);
}
 
//$i*25 spaces the characters 25 pixels apart
imagettftext($captcha,rand(14,20),$rotangle,($i*25),30,$txtcolor,"fonts/arial.ttf",substr($captchastr,($i-1),1));
}
 
for($i=1; $i<=4;$i++){
imageellipse($captcha,rand(1,200),rand(1,50),rand(50,100),rand(12,25),$txtcolor);
}
 
for($i=1; $i<=4;$i++){
imageellipse($captcha,rand(1,200),rand(1,50),rand(50,100),rand(12,25),$backcolor);
}
 
//Send the headers (at last possible time)
header('Content-type: image/png');
 
//Output the image as a PNG
imagePNG($captcha);
 
//Delete the image from memory
imageDestroy($captcha);
 
$_SESSION[captchastr] = $captchastr;
 
?>

How to enable GD library on WAMP5 – simplier than you think…

July 17th, 2010

How to enable GD library on Wamp5?

(This I assume you have running wamp5 on your system)

Click Wamp5 icon on lower right hand of your screen (see image)

wamp5

Click PHP settings …

wamp5

Click PHP extensions …

wamp5

If there’s an triangle already showing right across php_gd2 GD is already running and you can now create image on the fly(via PHP), but if no triangle  it is not enabled and to enable it just click and restart your server :)

Thats it. Its really amazing right :)