Monday, 15 November 2010

MySQL Table Types



MySQL supports various of table types or storage engines to allow you to optimize your database. The table types are available in MySQL are:

  • ISAM

  • MyISAM

  • InnoDB

  • BerkeleyDB (BDB)

  • MERGE

  • HEAP


The most important feature to make all the table types above distinction is transaction-safe or not. Only InnoDB and BDB tables are transaction safe and only MyISAM tables support full-text indexing and searching feature. MyISAM is also the default table type when you create table without declaring which storage engine to use. Here are some major features of each table types:

ISAM


ISAM had been deprecated and removed from version 5.x. All of it functionality entire replace by MyISAM. ISAM table has a hard size 4GB and is not portable.

MyISAM


MyISAM table type is default when you create table. MyISAM table work very fast but not transaction-safe. The size of MyISAM table depends on the operating system and the data file are portable from system to system. With MyISAM table type, you can have 64 keys per table and maximum key length of 1024 bytes.

InnoDB


Different from MyISAM table type, InnoDB table are transaction safe and supports row-level locking. Foreign keys are supported in InnoDB tables. The data file of InnoDB table can be stored in more than one file so the size of table depends on the disk space. Like the MyISAM table type, data file of InnoDB is portable from system to system. The disadvantage of InnoDB in comparison with MyISAM is it take more disk space.

BDB


BDB is similar to InnoDB in transaction safe. It supports page level locking but data file are not portable.

MERGE


Merge table type is added to treat multiple MyISAM tables as a single table so it remove the size limitation from MyISAM tables.

HEAP


Heap table is stored in memory so it is the fastest one. Because of storage mechanism, the data will be lost when the power failure and sometime it can cause the server run out of memory. Heap tables do not support columns with AUTO_INCREMENT, BLOB and TEXT characteristics.


 

Tuesday, 2 November 2010

Send mail from your localhost

Hello Friends !!

When you developing your site then you are facing a problem that how to send mail from your local host ?

Because when you are testing your project/site in localhost then this problem occurred. At that time you think about upload your site on server.

If you don’t want this type of uploading work and you want to test your mail form your localhost then here is the solution.

First of all open your xamp or wamp installed directory.

Then open php directory and find php.ini.

Then open this php.ini in notepad and find [mail function] in that file.

When you find it, remove semi colon before SMTP,smtp_port and sendmail_from.

Set this parameters like this :

SMTP=mail.test.com  //it indicates mail server

smtp_port=25            // it indicates port address

sendmail_from=test@test.com   // it indicates mail id from which you want to send mail

After this, please stop you xamp/wamp services, do refresh and start it again.

Thats it.. Now you can send mail from your localhost..

If you have any query or any confusion then feel free to comment me.

Thanks !!

[PHP] Email Attachment – PDF In Email Attachment

Hi Friends , yesterday I was working with email attachment and I wanted to send pdf file as email attachment but It was giving me so many problems. I have searched so many code for PDF attachment but no one was working So I start tp debug code and finally  made working pdf attachment code by pdf attachment in email worked successfully.

<?php



$fileatt = "test.pdf"; // Path to the file

$fileatt_type = "application/pdf"; // File Type

$fileatt_name = "test.pdf"; // Filename that will be used for the file as the attachment

$email_from = "noreply@hackingethics.com"; // Who the email is from

$email_subject = "Your attached file"; // The Subject of the email

$email_message = "Thanks for visiting <a href="http://www.hackingethics.com/" target="_blank" title="More about HackingEthics »">HackingEthics</a>.com! <br>";

$email_message .= "Thanks for visiting.<br>"; // Message that the email has in it

$email_to = "xyz@gmail.com"; // Who the email is to

$headers = "From: ".$email_from;

$file = fopen($fileatt,'rb');

$data = fread($file,filesize($fileatt));

fclose($file);

$semi_rand = md5(time());

$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

$headers .= "\nMIME-Version: 1.0\n" .

"Content-Type: multipart/mixed;\n" .

" boundary=\"{$mime_boundary}\"";

$email_message .= "This is a multi-part message in MIME format.\n\n" .

"--{$mime_boundary}\n" .

"Content-Type:text/html; charset=\"iso-8859-1\"\n" .

"Content-Transfer-Encoding: 7bit\n\n" .

$email_message .= "\n\n";

$data = chunk_split(base64_encode($data));

$email_message .= "--{$mime_boundary}\n" .

"Content-Type: {$fileatt_type};\n" .

" name=\"{$fileatt_name}\"\n" .

//"Content-Disposition: attachment;\n" .

//" filename=\"{$fileatt_name}\"\n" .

"Content-Transfer-Encoding: base64\n\n" .

$data .= "\n\n" .

"--{$mime_boundary}--\n";

$sent = @mail($email_to, $email_subject, $email_message, $headers);

if($sent) {

echo "Your email attachment has been Worked.";

} else {

die("Sorry but the email could not be sent. Please go back and try again!");

}

?>

Replace your email address in $email_to and filename in $fileatt and $fileatt_name.

 









Integration of Google Map in Websites (PHP,dot net,Java etc)

Hello friends I m a Web Developer so i want to share my knowledge with you.We all know about GoogleMap, now if you want to integrate Google Map in your website or in your client website then i m giving you some tips about Google map integration in website (PHP,.NET,Java etc).

To integrate Google Map in Website then firstly you have one API key,from this API key you can use Google Map in your website. This API key is Unique for every website (this API key working for all subdirecories in a website,So always use Root directory to get API key ) , so here is the link to generate API key for Google Map. (Click here to Generate API key for Google Map).Now you can check Google Map Documentation for integration in Google Map in Website.you can find all things in this Documentation but But now if you wana some more Stuffs in Google Map like Position Overview,Markers on places,Zoom,Double Click Zoom,To here from Here direction,Markers with info windows,Tabbed Info WIndows,Custom Zoom Slider,Context menus and also Adding your own custom map with examples then i know one more website link which have this all stuffs with simple and sweet examples.You can understand this all examples easily and also you can integrate in your website. (Click here for Google Map integration in Website Tutorial)
If you have any problem in Google Map you can contact me, I will try my best to help you in Google Map

How to integrate paypal pro in to your php site....

The following code is used to integrate payment module in your site

create one file with name paypal.php [or any name you wish]

paypal.php file contains the following code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>The Popout - Paypal Payment</title>
<link rel="icon" href="favicon.ico" type="image/x-icon" />
<link rel="icon" href="images/1.ico" type="image/x-icon">
<link rel="shortcut icon" href="images/1.ico" type="image/x-icon">
</head>
<body oncontextmenu="return false" onLoad="document.paypal_form.submit();">
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" name="paypal_form">
<input type="hidden" name="image" src="images/payment_sub.gif" border="0" alt="Make payments with PayPal - it's fast, free and secure!">
<input type="hidden" name="cmd" value="_xclick-subscriptions">
<input type="hidden" name="business" value="clientpaypalid@clientsite.com"> <!--Value is Client paypal id for his site, it is mandatary-->
<input type="hidden" name="item_name" value="Premium Membership">
<input type="hidden" name="buyer_credit_promo_code" value="1">
<input type="hidden" name="buyer_credit_product_category" value="1">
<input type="hidden" name="buyer_credit_shipping_method" value="1">
<input type="hidden" name="buyer_credit_user_address_change" value="1">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="AUD"> <!--Value is currency code-->
<input type="hidden" name="lc" value="US"> <!--Country code-->
<input type="hidden" name="bn" value="PP-SubscriptionsBF">
<input type="hidden" name="a3" value="<?=$amount?>"> <!--Value is the amount how much you collect from user, this value is mandatary, you can get this value from the hidden filed of previous form you come from or get from passing to the url, best to get from hidden field, if you get from url it is not safe because we give chance to the user to change the amount value-->
<input type="hidden" name="p3" value="1">
<input type="hidden" name="t3" value="M">
<input type="hidden" name="src" value="1">
<input type="hidden" name="sra" value="1">
<input type="hidden" name="first_name" value="<?=$firstname?>"> <!--Value for this user details is not mandatary, these fields will be filled in the paypal site if we are not passing. If we pass these values these values will be autofilledin in the paypal site-->
<input type="hidden" name="last_name" value="<?=$lastname?>">
<input type="hidden" name="address1" value="<?=$address?>">
<input type="hidden" name="city" value="<?=$city?>">
<input type="hidden" name="state" id="state" value="<?=$state?>">
<input type="hidden" name="zip" value="<?=$zip?>">
<input type="hidden" name="country" id="country_code" value="<?=$country_code?>">
<input type="hidden" name="H_PhoneNumber" value="<?=$H_PhoneNumber?>">
<input type="hidden" name="email" value="<?=$email?>">
<input type="hidden" name="credit_card_type" id="credit_card_type" value="<?=$credit_card_type?>">
<input type="hidden" name="cc_number" value="<?=$card_num?>">
<input type="hidden" name="expdate_month" value="<?=$exp_month?>">
<input type="hidden" name="expdate_year" value="<?=$exp_year?>">
<input type="hidden" name="cvv2_number" value="<?=$card_code?>">
<input type="hidden" name="return" value="http://www.popout.com.au/dev/paypalstatus.php?msg=success"> <!--this is the page redirecting from paypal site when the user gives all correct details-->
<input type="hidden" name="cancel_return" value="http://www.popout.com.au/dev/paypalstatus.php?msg=failure"> <!--this is the page redirecting from paypal site when the user gives false details-->
<input type="submit" name="submit" value="continue" />
</form>
</body>
</html>