Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

September 19, 2009

date = date + 30 days in mysql

Add 30days to the current date and update in mysql. Try this code in PHP to get the future date (30 days interval),

<?php

$current_date = date("d-m-Y");
list($day, $month, $year) = split("-", $current_date);
$timeStamp = mktime(0,0,0,$month,$day,$year);
$timeStamp = $timeStamp + (30 * 24 * 60 * 60); #Add 30 days, in seconds
$future_date = date("d-m-Y", $timeStamp); #output the result

echo $future_date;

?>

July 18, 2009

Total number of php built-in functions

Hi all, you know that the total number of php built-in functions available is 1263

get_defined_functions() will return the built-in function list in php

To view those function list just execute the following code and have a look on yours

<?php

$functions_list = get_defined_functions();

$i = 1;
foreach($functions_list['internal'] as $function_name) {
echo $i . “. ” . $function_name . “<br/>”;
$i++;
}

?>

June 22, 2009

Unable to find the socket transport “ssl” - did you forget to enable it when you configured PHP?

Last week while implementing google docs API i got this error "Unable to find the socket transport “ssl” - did you forget to enable it when you configured PHP?". I searched for the solution and fixed at last.

Here is the solution to the above problem,

uncommented the line in php.ini
;extension=php_openssl.dll

Other related blog post

http://www.boringguys.com/2007/07/20/unable-to-find-the-socket-transport-ssl-did-you-forget-to-enable-it-when-you-configured-php/

"Ran into this error recently… here’s how to fix it, you have to install OpenSSL on your system. For OpenSSL your PHP config values look like this:

–with-openssl[=DIR] Include OpenSSL support (requires OpenSSL >= 0.9.6)

So, if you’ve compiled from scratch, you can just recompile adding this flag to your configure command."

May 21, 2009

Jcrop plugin for image crop in jQuery

Jcrop is a cross-browser jQuery image crop plugin, a quick and easy way to add image cropping functionality to your web application. It combines the ease-of-use of a typical jQuery plugin with a powerful cross-platform DHTML cropping engine..







Some features of Jcrop:

* Attaches simply to any image in your HTML page
* Supports aspect ratio locking
* Callbacks for selection done, or while moving
* Keyboard support for nudging selection
* Support for CSS styling
* Advanced API including animation support

An example of this plugin here & a sample PHP code to complete the server-side of the crop here.

Requirements: jQuery
Compatibility: All Major Browsers
Website: http://deepliquid.com/content/Jcrop.html
Demo: http://deepliquid.com/content/Jcrop_Examples.html

April 25, 2009

Send mail with attachment in php

This code will help you with attachment of files in anytype in sending a mail with php

include this input field inside "form" tag
<input type="file" name="fileatt" size="22" />
<input type="submit" name="career_submit" size="22" />

When the page is submitted use the following code to send the mail to the receipent with the attachment.

if(isset($_REQUEST['career_submit'])) {
/*@@@@@@@@@@@--- File Type --- @@@@@@@@@@@*/
$fileatt_name = $_FILES['fileatt']['name'];
$fileName = $_FILES['fileatt']['tmp_name'];
$fileatt_type = "application/octet-stream";
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

$email_from = $_REQUEST["email"]; // Who the email is from
$email_subject = "Mail Subject"; // The Subject of the email
$email_to = "example@example.com"; // Who the email is too

$headers = "From: ".$email_from;

/*@@@@@@@--- File Permissions --- @@@@@@@@*/
$file = fopen($fileName,'rw');
@$data = fread($file,filesize($fileName));
@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 .= 'Your Message.....'; // Mail Content Comes Here

$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";

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