Hi,
I always prepare my documents in excel and i like it. I faced the problem when entering dates in the column, those are always formated to mm/dd/yy format even i entered in whatever format.
The solution i got is : Select formtat cells -> numbers -> date -> select custom format
Friday, April 16, 2010
Drupal load block content in any page
To Load block content in any page use below code in drupal
$blockView = module_invoke(, 'block', 'view', );
print($blockView['content']);
Where modulename is the type of the block, i.e you can create blocks in different ways like using views module, using taxonomyblock module etc. and delta is the numeric id of the block.
Example: below is the code to call a block which was generated using taxonomymenu block module.
$blockView = module_invoke('taxonomyblocks', 'block', 'view', 2);
print($blockView['content']);
?>
Display blocks based on some content types
$match = FALSE;
// block is visible on the content types entered here
$types = array('story' => 1, 'page' => 1);
$url = request_uri();
if ((arg(0) == 'node') && is_numeric(arg(1))) {
$node = node_load(arg(1));
$match = isset($types[$node->type]);
}
// block is invisible on URLs entered here
if (strpos($url, "edit")) {
$match = FALSE;
}
// copy paste these for additional URLs
if (strpos($url, "admin")) {
$match = FALSE;
}
return $match;
?>
Reference
http://drupal.org/node/26502
http://drupal.org/node/345361
$blockView = module_invoke(
print($blockView['content']);
Where modulename is the type of the block, i.e you can create blocks in different ways like using views module, using taxonomyblock module etc. and delta is the numeric id of the block.
Example: below is the code to call a block which was generated using taxonomymenu block module.
$blockView = module_invoke('taxonomyblocks', 'block', 'view', 2);
print($blockView['content']);
?>
Display blocks based on some content types
$match = FALSE;
// block is visible on the content types entered here
$types = array('story' => 1, 'page' => 1);
$url = request_uri();
if ((arg(0) == 'node') && is_numeric(arg(1))) {
$node = node_load(arg(1));
$match = isset($types[$node->type]);
}
// block is invisible on URLs entered here
if (strpos($url, "edit")) {
$match = FALSE;
}
// copy paste these for additional URLs
if (strpos($url, "admin")) {
$match = FALSE;
}
return $match;
?>
Reference
http://drupal.org/node/26502
http://drupal.org/node/345361
Thursday, April 15, 2010
Secure files transfer through SSH
http://www.unixwiz.net/techtips/putty-openssh.html
http://www.lesbell.com.au/Home.nsf/b8ec57204f60dfcb4a2568c60014ed0f/ed0d3f0199e49f57ca25734000023a77?OpenDocument
Some times you need to login two hosts.
First login:
ssh pete2@stickerguy.net
password:
su
root password:
Next server
ssh stickerguy@web2.greatbasin.net -p 2222
password:
Now you connected two hosting servers and you are in second server. To come out of second server press exit.
The below command will copy the first server files to second server.
scp -r pete2@stickerguy.net:/usr/local/lib/php/Services/ ./Services/
http://www.lesbell.com.au/Home.nsf/b8ec57204f60dfcb4a2568c60014ed0f/ed0d3f0199e49f57ca25734000023a77?OpenDocument
Some times you need to login two hosts.
First login:
ssh pete2@stickerguy.net
password:
su
root password:
Next server
ssh stickerguy@web2.greatbasin.net -p 2222
password:
Now you connected two hosting servers and you are in second server. To come out of second server press exit.
The below command will copy the first server files to second server.
scp -r pete2@stickerguy.net:/usr/local/lib/php/Services/ ./Services/
Wednesday, April 14, 2010
Drupal get term details for particular node you are viewing
$terms = taxonomy_node_get_terms($node);
print_r($terms);
print_r($terms);
Monday, April 12, 2010
Make will_paginate as ajax pagination
Add below code in your public/javascripts/application.js
document.observe("dom:loaded", function() {
// the element in which we will observe all clicks and capture
// ones originating from pagination links
var container = $(document.body)
if (container) {
var img = new Image
img.src = '/images/spinner.gif'
function createSpinner() {
return new Element('img', { src: img.src, 'class': 'spinner' })
}
container.observe('click', function(e) {
if (e.element().match('img'))
var el = e.element().ancestors()[0]
else
var el = e.element()
if (el.match('.pagination a')) {
el.up('.pagination').insert(createSpinner())
new Ajax.Request(el.href, { method: 'get' })
e.stop()
}
})
}
})
In app/controllers/controller.rb file add below
def product
@similar_products = Product.paginate(:per_page => 4,:page=>params[:similar_products_page],:conditions => ["shopping_category_id = ? and id != ?", @product.shopping_category_id, @product.id])
@featureproduct = Product.paginate(:per_page =>1, :page=>params[:featureproduct_page], :conditions => ["featured = ? and id != ?", 1, @product.id], :order=>'rand()', :limit => 3)
if params[:similar_products_page]
respond_to do |format|
#format.html
format.js {
render :update do |page|
# 'page.replace' will replace full "results" block...works for this example
# 'page.replace_html' will replace "results" inner html...useful elsewhere
page.replace_html 'related', :partial => 'related_products'
end
}
end
end
if params[:featureproduct_page]
respond_to do |format|
#format.html
format.js {
render :update do |page|
# 'page.replace' will replace full "results" block...works for this example
# 'page.replace_html' will replace "results" inner html...useful elsewhere
page.replace_html 'featured', :partial => 'product_featured'
end
}
end
end
In app/views/products/_product_featured.rb
<%= will_paginate @featureproduct, :param_name => 'featureproduct_page', :prev_label => image_tag('shopping/left_arrow.jpg'), :next_label => image_tag('shopping/right_arrow.jpg'), :page_links=>false%>
In app/views/products/_related_products.rb
<%= will_paginate @similar_products,:param_name => 'similar_products_page' %>
Now your pagination become ajax.
document.observe("dom:loaded", function() {
// the element in which we will observe all clicks and capture
// ones originating from pagination links
var container = $(document.body)
if (container) {
var img = new Image
img.src = '/images/spinner.gif'
function createSpinner() {
return new Element('img', { src: img.src, 'class': 'spinner' })
}
container.observe('click', function(e) {
if (e.element().match('img'))
var el = e.element().ancestors()[0]
else
var el = e.element()
if (el.match('.pagination a')) {
el.up('.pagination').insert(createSpinner())
new Ajax.Request(el.href, { method: 'get' })
e.stop()
}
})
}
})
In app/controllers/controller.rb file add below
def product
@similar_products = Product.paginate(:per_page => 4,:page=>params[:similar_products_page],:conditions => ["shopping_category_id = ? and id != ?", @product.shopping_category_id, @product.id])
@featureproduct = Product.paginate(:per_page =>1, :page=>params[:featureproduct_page], :conditions => ["featured = ? and id != ?", 1, @product.id], :order=>'rand()', :limit => 3)
if params[:similar_products_page]
respond_to do |format|
#format.html
format.js {
render :update do |page|
# 'page.replace' will replace full "results" block...works for this example
# 'page.replace_html' will replace "results" inner html...useful elsewhere
page.replace_html 'related', :partial => 'related_products'
end
}
end
end
if params[:featureproduct_page]
respond_to do |format|
#format.html
format.js {
render :update do |page|
# 'page.replace' will replace full "results" block...works for this example
# 'page.replace_html' will replace "results" inner html...useful elsewhere
page.replace_html 'featured', :partial => 'product_featured'
end
}
end
end
In app/views/products/_product_featured.rb
<%= will_paginate @featureproduct, :param_name => 'featureproduct_page', :prev_label => image_tag('shopping/left_arrow.jpg'), :next_label => image_tag('shopping/right_arrow.jpg'), :page_links=>false%>
In app/views/products/_related_products.rb
<%= will_paginate @similar_products,:param_name => 'similar_products_page' %>
Now your pagination become ajax.
Multiple paginations in single page using will paginate
If you want to display multiple paginations in a single page then you have to change the detault page parameter. to change the default :page => params[:page] use below process
In controller add below
@featured = Product.paginate(:page => params[:featured_page])
@related = Product.paginate(:page => params[:related_page])
In view add below
<%= will_paginate @featured, :param_name => 'featured_page' %>
<%= will_paginate @related, :param_name => 'related_page' %>
In controller add below
@featured = Product.paginate(:page => params[:featured_page])
@related = Product.paginate(:page => params[:related_page])
In view add below
<%= will_paginate @featured, :param_name => 'featured_page' %>
<%= will_paginate @related, :param_name => 'related_page' %>
Saturday, April 3, 2010
Linux ssh Tips
Connect to ssh
You can connect to ssh using root@hostname.com If you have root access
If you dont have root access then do as below
1. First login ssh user@host1.com
2. su
3. Password: root password
After you login to host1's root.
then ssh user@host2.com -p 2222
host2password :
Now you logged into host2 from host1's root.
To come out to host1. use exit.
stickerguy@web2.greatbasin.net
locate is the command to search any folder or files.
You can connect to ssh using root@hostname.com If you have root access
If you dont have root access then do as below
1. First login ssh user@host1.com
2. su
3. Password: root password
After you login to host1's root.
then ssh user@host2.com -p 2222
host2password :
Now you logged into host2 from host1's root.
To come out to host1. use exit.
stickerguy@web2.greatbasin.net
locate is the command to search any folder or files.
Drupal usefull reference URLs
Usefull modules
Handbooks
http://drupal.org/handbooks
http://www.nicklewis.org/40-essential-drupal-6-modules
http://www.eadhoc.com/2010/03/drupal-terminology.html
Node auto term.It will create categories automatically when node contetn added.
http://www.facebook.com/note.php?note_id=196164430516
Node autotem
http://blog.adyax.com/2009/03/english-drupal-tutorial-node-auto-term-taxonomy-tips-and-jquery-menu-api-in-use/
Drupal 6
http://drupal.org/node/733182
Module functions
http://drupalcontrib.org/api/drupal/contributions--nat--nat.module/6
Taxonomy
http://drupal.org/node/2498
Reasons for why you use drupal
http://www.tajahdev.com/Resource/drupal.htm
15 Usefull views modules
http://ntt.cc/2009/01/28/15-userful-views-module-for-drupal.html
Views theming
http://www.packtpub.com/article/drupal-6-attachment-views-page-views-theming
http://realtech.burningbird.net/content-management/planet-drupal-entries/drupal-views-and-taxonomy-pages
http://zugec.com/drupal/theme-wizard-in-views-with-drupal-5
Advanced taxonomy term blocks
http://www.pixelclever.com/documentation-advanced-taxonomy-blocks-module-drupal-6
Views Help
http://views-help.doc.logrus.com/
http://drupal.org/node/59157
http://drupal.org/files/issues/nat-views-support-term-node-count_1.patch
Handbooks
http://drupal.org/handbooks
http://www.nicklewis.org/40-essential-drupal-6-modules
http://www.eadhoc.com/2010/03/drupal-terminology.html
Node auto term.It will create categories automatically when node contetn added.
http://www.facebook.com/note.php?note_id=196164430516
Node autotem
http://blog.adyax.com/2009/03/english-drupal-tutorial-node-auto-term-taxonomy-tips-and-jquery-menu-api-in-use/
Drupal 6
http://drupal.org/node/733182
Module functions
http://drupalcontrib.org/api/drupal/contributions--nat--nat.module/6
Taxonomy
http://drupal.org/node/2498
Reasons for why you use drupal
http://www.tajahdev.com/Resource/drupal.htm
15 Usefull views modules
http://ntt.cc/2009/01/28/15-userful-views-module-for-drupal.html
Views theming
http://www.packtpub.com/article/drupal-6-attachment-views-page-views-theming
http://realtech.burningbird.net/content-management/planet-drupal-entries/drupal-views-and-taxonomy-pages
http://zugec.com/drupal/theme-wizard-in-views-with-drupal-5
Advanced taxonomy term blocks
http://www.pixelclever.com/documentation-advanced-taxonomy-blocks-module-drupal-6
Views Help
http://views-help.doc.logrus.com/
http://drupal.org/node/59157
http://drupal.org/files/issues/nat-views-support-term-node-count_1.patch
Copying files from one host to another with scp command
Best Reference
http://www.lesbell.com.au/Home.nsf/b8ec57204f60dfcb4a2568c60014ed0f/04eaff076bce249dca256fb6007f53e5?OpenDocument
Copy entire folder with all files and subfolders
user@user:~$ scp -r /var/www/localdir/ user@192.168.10.150:/var/www/
In windows
Putty and pscp are excellent tools for ssh and scp operations in windows os.
Download putty and pscp softwares from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
They are self executable files so no need to install those just place in some folder ex: c:\programfiles\putty folder and set the path in command prompt.
open command prompt (DOS Prompt)from start -> run -> cmd
set PATH=C:\path\to\putty\directory;%PATH%
So to copy the file /etc/hosts from the server example.com as user fred to the file c:\temp\example-hosts.txt, you would type:
pscp fred@example.com:/etc/hosts c:\temp\example-hosts.txt
To send (a) file(s) to a remote server:
pscp [options] source [source...] [user@]host:target
So to copy the local file c:\documents\foo.txt to the server example.com as user fred to the file /tmp/foo you would type:
pscp c:\documents\foo.txt fred@example.com:/tmp/foo
You can use wildcards to transfer multiple files in either direction, like this:
pscp c:\documents\*.doc fred@example.com:docfiles
pscp fred@example.com:source/*.c c:\source
Copy entire folder from remote server to local computer along with files and subfolders
pscp -r user@example.com:source/* c:\source
Ref : http://www.jfitz.com/tips/ssh_for_windows.html
http://www.lesbell.com.au/Home.nsf/b8ec57204f60dfcb4a2568c60014ed0f/04eaff076bce249dca256fb6007f53e5?OpenDocument
Copy entire folder with all files and subfolders
user@user:~$ scp -r /var/www/localdir/ user@192.168.10.150:/var/www/
In windows
Putty and pscp are excellent tools for ssh and scp operations in windows os.
Download putty and pscp softwares from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
They are self executable files so no need to install those just place in some folder ex: c:\programfiles\putty folder and set the path in command prompt.
open command prompt (DOS Prompt)from start -> run -> cmd
set PATH=C:\path\to\putty\directory;%PATH%
So to copy the file /etc/hosts from the server example.com as user fred to the file c:\temp\example-hosts.txt, you would type:
pscp fred@example.com:/etc/hosts c:\temp\example-hosts.txt
To send (a) file(s) to a remote server:
pscp [options] source [source...] [user@]host:target
So to copy the local file c:\documents\foo.txt to the server example.com as user fred to the file /tmp/foo you would type:
pscp c:\documents\foo.txt fred@example.com:/tmp/foo
You can use wildcards to transfer multiple files in either direction, like this:
pscp c:\documents\*.doc fred@example.com:docfiles
pscp fred@example.com:source/*.c c:\source
Copy entire folder from remote server to local computer along with files and subfolders
pscp -r user@example.com:source/* c:\source
Ref : http://www.jfitz.com/tips/ssh_for_windows.html
Tuesday, March 30, 2010
Export and import database to and from remote servers through telnet
Hi, If you want to take database backup from one server and import it into another remote server use the below process.
Import command at terminal or dos
mysql -u user_login -p database_name < /path_to_the_file/my_backup.sql
Export command at terminal or dos
mysqldump -u user_login -p database_name > /path_to_the_file/my_backup.sql
Database Backup
connect to remote host with SSH from termail using below command
#ssh user@host.com
password:
After login, crate one folder to store the backup file and make it writeble, then run the beloc ommand to take backup for the whole database
#mysqldump -u dbusername -p dbname > dbbackup.sql
It will ask you the dbpassword
After download ddbackup.sql and transfer to new host where you have to set up the database..
connect to remote host with SSH
#mysql -u dbusername -p dbname -e 'source dbbackup.sql'
It wil ask you the dbpassword.
The other way, which is even cooler, and more secure, assuming you have ssh access on both machines (this, again, is a direct dump-to-import):
mysqldump -ux -px database | ssh me@newhost "mysql -ux -px database"
This will dump the data to stdout, pipe it to ssh @ the newhost, and into mysql. Of course, replace all x's with username's and password.
If you want to keep two databases equal, you can use rsync (if your system supports it) to do it by creating a simple script:
rsync you@yourserver::share/path/to/mysql/data/* /path/on/the/other/server/
that you call with a cron job every 10 minutes/1 hour/1day/...
This way, whenever your database change, rsync will find the difference and would transfer ONLY the bytes that have changed.
Ref: http://www.webhostingtalk.com/archive/index.php/t-226992.html
Import command at terminal or dos
mysql -u user_login -p database_name < /path_to_the_file/my_backup.sql
Export command at terminal or dos
mysqldump -u user_login -p database_name > /path_to_the_file/my_backup.sql
Database Backup
connect to remote host with SSH from termail using below command
#ssh user@host.com
password:
After login, crate one folder to store the backup file and make it writeble, then run the beloc ommand to take backup for the whole database
#mysqldump -u dbusername -p dbname > dbbackup.sql
It will ask you the dbpassword
After download ddbackup.sql and transfer to new host where you have to set up the database..
connect to remote host with SSH
#mysql -u dbusername -p dbname -e 'source dbbackup.sql'
It wil ask you the dbpassword.
The other way, which is even cooler, and more secure, assuming you have ssh access on both machines (this, again, is a direct dump-to-import):
mysqldump -ux -px database | ssh me@newhost "mysql -ux -px database"
This will dump the data to stdout, pipe it to ssh @ the newhost, and into mysql. Of course, replace all x's with username's and password.
If you want to keep two databases equal, you can use rsync (if your system supports it) to do it by creating a simple script:
rsync you@yourserver::share/path/to/mysql/data/* /path/on/the/other/server/
that you call with a cron job every 10 minutes/1 hour/1day/...
This way, whenever your database change, rsync will find the difference and would transfer ONLY the bytes that have changed.
Ref: http://www.webhostingtalk.com/archive/index.php/t-226992.html
Saturday, March 27, 2010
Drupal Image gallery creation
http://jamestombs.co.uk/2009-05-12/create-an-album-based-image-gallery-in-drupal-6-using-cck-and-views/1045
http://www.primalmedia.com/blog/building-better-drupal-photo-gallery
http://www.primalmedia.com/blog/building-better-drupal-photo-gallery
Background color problem for fckeditor in Drupal
When you install fckeditor module in drupal you might get problem that editor's background color is applied from body background color. To fix this background color problem add another line in fckeditor.config.js:
FCKConfig.EditorAreaStyles = "body{background:#FFFFFF;text-align:left;}";
Other tips for fckeditor in drupal http://drupal.fckeditor.net/tricks
FCKConfig.EditorAreaStyles = "body{background:#FFFFFF;text-align:left;}";
Other tips for fckeditor in drupal http://drupal.fckeditor.net/tricks
Friday, March 26, 2010
Get IP address of the site visitor in rails application
In RAILS_ROOT/app/controllers/show_my_ip_controller.rb
class ShowMyIpController < ApplicationController
def index
@client_ip = request.remote_ip
end
end
In RAILS_ROOT/app/views/show_my_ip/index.html.erb
Your IP address is <%= @client_ip %>
class ShowMyIpController < ApplicationController
def index
@client_ip = request.remote_ip
end
end
In RAILS_ROOT/app/views/show_my_ip/index.html.erb
Your IP address is <%= @client_ip %>
Tuesday, March 23, 2010
Commands to start apache server and mysql server in linux
To start Apache webserver in linux (LAMP)
#service httpd start
the above command will start both apache and mysql servers.
To start Mysql server in linux (LAMP)
#service mysqld start
#service httpd start
the above command will start both apache and mysql servers.
To start Mysql server in linux (LAMP)
#service mysqld start
Thursday, March 18, 2010
Working with Float values
While you are working with float numbers and you should always want to display 1 or 2 numbers only after precission ex: You like to display 5.30 instead of 5.29088388434. To display in that format we have to use below functions
In Ruby:
f=1.23456
puts sprintf('%.2f', f).sub(/0{1,2}$/, '')
In php:
$$grandtotal = $rate*$miles;
echo number_format($grandtotal,2);
?>
In Ruby:
f=1.23456
puts sprintf('%.2f', f).sub(/0{1,2}$/, '')
In php:
$$grandtotal = $rate*$miles;
echo number_format($grandtotal,2);
?>
Monday, March 15, 2010
Multiple layouts for each Wordpress Page
The solution:
Edit ‘page.php’ to check what page your on, and then load the appropriate template.
The implementation:
If you edit page.php you’ll notice that it calls the get_header() and get_footer() functions. This is about the only bit of code that we want to keep in this file.
First Step:
First, make a copy of page.php and give it a name. This is your first template. Delete the header and footer calls from your template, because we’re going to load this into page.php, and it will have already called them.
Second Step:
Open page.php and delete everything between the header and footer calls. In this space, add a PHP conditional that uses the is_page() function.
if(is_page(107) == true) {
include ‘page_full.php’;
} else {
include ‘page_twocolumn.php’;
}
?>
Here’s an example of what I did to load multiple page layouts:
if(is_page(107) == true) {
include ‘page_films.php’;
} else if(is_page(array(518, 28, 13)) == true) {
include ‘page_full.php’;
} else {
include ‘page_twocolumn.php’;
}
?>
This sets page with ID 107 to use the template specific for the ‘films’ page. It also sets pages with ID’s 518, 28, and 13 to use the full page layout. All others use the two column layout.
That’s it!
Edit ‘page.php’ to check what page your on, and then load the appropriate template.
The implementation:
If you edit page.php you’ll notice that it calls the get_header() and get_footer() functions. This is about the only bit of code that we want to keep in this file.
First Step:
First, make a copy of page.php and give it a name. This is your first template. Delete the header and footer calls from your template, because we’re going to load this into page.php, and it will have already called them.
Second Step:
Open page.php and delete everything between the header and footer calls. In this space, add a PHP conditional that uses the is_page() function.
if(is_page(107) == true) {
include ‘page_full.php’;
} else {
include ‘page_twocolumn.php’;
}
?>
Here’s an example of what I did to load multiple page layouts:
if(is_page(107) == true) {
include ‘page_films.php’;
} else if(is_page(array(518, 28, 13)) == true) {
include ‘page_full.php’;
} else {
include ‘page_twocolumn.php’;
}
?>
This sets page with ID 107 to use the template specific for the ‘films’ page. It also sets pages with ID’s 518, 28, and 13 to use the full page layout. All others use the two column layout.
That’s it!
Tuesday, February 23, 2010
css tric to set containers height with minimum and auto values
.selector {
width:200px;
min-height:100px;
height:auto !important;
height:500px;
border:1px solid #000000;
padding:5px;
}
when you assign this class to any contaner like div or span, its minimum height is 100px if there is no content, then it is automatically exanded instead of scrolling when loaded content is more. Maximum height is 500px it is for IE browser only.
width:200px;
min-height:100px;
height:auto !important;
height:500px;
border:1px solid #000000;
padding:5px;
}
when you assign this class to any contaner like div or span, its minimum height is 100px if there is no content, then it is automatically exanded instead of scrolling when loaded content is more. Maximum height is 500px it is for IE browser only.
Monday, February 22, 2010
Sending emails with Gmail smtp server rather than your server's smtp
Download the phpmailer classes At http://sourceforge.net/projects/phpmailer/files/phpmailer%20for%20php5_6/
Then use the below code to send emails.
require(“includes/class.phpmailer.php”);
$mailer = new PHPMailer();
$mailer->IsSMTP();
$mailer->Host = ’ssl://smtp.gmail.com:465′;
$mailer->SMTPAuth = TRUE;
$mailer->Username = ‘{somename}@gmail.com’; // Change this to your gmail adress
$mailer->Password = ‘{password}’; // Change this to your gmail password
$mailer->From = ‘{someid}@gmail.com’; // This HAVE TO be your gmail adress
$mailer->FromName = ‘Venkat’; // This is the from name in the email, you can put anything you like here
$mailer->Body = ‘Message body’;
$mailer->Subject = ‘Message subject’;
$mailer->AddAddress(‘{toaddress email id}’); // This is where you put the email adress of the person you want to mail
if(!$mailer->Send())
{
echo “Message was not sent
”;
echo “Mailer Error: ” . $mailer->ErrorInfo;
}
else
{
echo “Message has been sent”;
}
?>
Then use the below code to send emails.
require(“includes/class.phpmailer.php”);
$mailer = new PHPMailer();
$mailer->IsSMTP();
$mailer->Host = ’ssl://smtp.gmail.com:465′;
$mailer->SMTPAuth = TRUE;
$mailer->Username = ‘{somename}@gmail.com’; // Change this to your gmail adress
$mailer->Password = ‘{password}’; // Change this to your gmail password
$mailer->From = ‘{someid}@gmail.com’; // This HAVE TO be your gmail adress
$mailer->FromName = ‘Venkat’; // This is the from name in the email, you can put anything you like here
$mailer->Body = ‘Message body’;
$mailer->Subject = ‘Message subject’;
$mailer->AddAddress(‘{toaddress email id}’); // This is where you put the email adress of the person you want to mail
if(!$mailer->Send())
{
echo “Message was not sent
”;
echo “Mailer Error: ” . $mailer->ErrorInfo;
}
else
{
echo “Message has been sent”;
}
?>
Friday, February 19, 2010
Cron job settings in server
Cron jobs are used to run a script automatically with some time interval Example if you want to send emails daily morining to all newsletter subscribers when new jobs were added to your jobs portal these cron jobs are used. Below are the steps to setup cron jobs
For php:
Login to hosting server and goto the cron job settings page and select the time interval you want to run the script then give the command to run the php file as below
php /path-to-your-phpfile.php
(OR)
/usr/local/bin/php /path-to-your-phpfile.php
For Ruby:
/usr/local/bin/ruby /home/user/domainname/script/runner /home/user/domainname/app/cron_job.rb
For php:
Login to hosting server and goto the cron job settings page and select the time interval you want to run the script then give the command to run the php file as below
php /path-to-your-phpfile.php
(OR)
/usr/local/bin/php /path-to-your-phpfile.php
For Ruby:
/usr/local/bin/ruby /home/user/domainname/script/runner /home/user/domainname/app/cron_job.rb
Subscribe to:
Posts (Atom)