Tuesday 15 November 2011

set_time_limit in php, set_time_limit in php5, why set_time_limit?

WHY set_time_limit ?
It is used to run the scripts in the file for a particular amount of time. If we just put set_time_limit(1) then the setting will allow the file to run the script for 1 second and if the time exceeds then it will throw the fatal error

Set_time_limit(0) – No time limit will be set, but I didt checked my MAX_EXECUTION_TIME, if there is still problem in the set_time_limit please check with the MAX_EXECUTION_TIME in the php.ini settings.

Let us check some examples
set_time_limit(0);
function ran()
{
$i=100000;
for ($j=0;$j<$i;$j++)
{
echo $j;
}
}
$gg=ran();
?>
>>>>> WONT THROW ANY ERROR


set_time_limit(1);
function ran()
{
$i=100000;
for ($j=0;$j<$i;$j++)
{
echo $j;
}
}
$gg=ran();
?>

>>>>>> HERE WE SET THIS TO 1 SECOND BUT THE SCRIPT NEEDS TO RUN A LOOP FOR 100000 SO IT WILL THROW THE ERROR LIKE BELOW
Fatal error: Maximum execution time of 1 second exceeded in ------------------------------------------------------------------------

Saturday 29 October 2011

Stored procedure in MYSQL PHP / MYSQLi

Before proceeding with stored procedure, just confirm whether your server is having all the enough latest versions, please check with MYSQL for the same

While trying i found MYSQLi works well when compared to MYSQL.

Tuesday 29 March 2011

Know the status of your email in php

This is my requesting php file

This is my response php file


Thursday 17 March 2011

CRON Path and settings in server


@minute - * * * * *


And paths that you need to try

/web/cgi-bin/php5 "$HOME/html/public_html/my.php"

php /home/*******/public_html/my.php

/home/*******/public_html

/web/cgi-bin/php5 -q /home/*******/public_html/my.php

/web/cgi-bin/php5 -q /home/*******/public_html/my.php

/web/cgi-bin/php5 $HOME/html/home/*******/public_html/html/my.php

/web/cgi-bin/php5 “$HOME/*******/public_html/my.php?

------------------------------------------------------------------------------
/usr/bin/php /home/*******/public_html/my.php
-----------------------------------------------------------------------------

Monday 7 March 2011

Creating multiple like in a dynamic php page

Creating multiple like in a dynamic php page

1) Create the FB like code

2) Two formats

<.script src="http://connect.facebook.net/en_US/all.js#xfbml=1"><.fb:like href="http://*****/fb_like.php" show_faces="true" width="450" font="verdana">

<.iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2F*******%2F******%2Ffb_like.php&layout=standard&show_faces=true&width=450&action=like&font=verdana&colorscheme=light&height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true">

3) I just used the first method

<.script src="http://connect.facebook.net/en_US/all.js#xfbml=1">

<.fb:like href="http://*****/fb_like.php?id=1" show_faces="true" width="450" font="verdana">

<.fb:like href="http://*****/fb_like.php?id=2" show_faces="true" width="450" font="verdana">

<.fb:like href="http://*****/fb_like.php?id=3" show_faces="true" width="450" font="verdana">

<.fb:like href="http://*****/fb_like.php?id=4" show_faces="true" width="450" font="verdana">



=========================

the above one is a XFBML (script code) that is non iframe code

Tuesday 1 March 2011

group by order by

select * from ".DB_table." Where id IS NOT NULL GROUP BY blog_date ORDER BY id DESC

Tuesday 22 February 2011

Add Search form in wordpress

have the code where ever you want

<...........form method='get' id='searchform' action='<.....?php bloginfo('home'); ........?..>/'>
<......div>
<........input type='text' size='18' value=' ' name='s' id='s' />
<.....input type='submit' id='searchsubmit' value='Search' class='btn' />
<....../div>

Wordpress add small description in the index page or the page you want to show

This is the function in your template function.php

if(!function_exists('getPageContent'))
{
function getPageContent($pageId,$max_char)
{
if(!is_numeric($pageId))
{
return;
}
global $wpdb;
$nsquery = 'SELECT DISTINCT * FROM ' . $wpdb->posts .
' WHERE ' . $wpdb->posts . '.ID=' . $pageId;
$post_data = $wpdb->get_results($nsquery);
if(!empty($post_data))
{
foreach($post_data as $post)
{
$text_out=nl2br($post->post_content);
$text_out=str_replace(']]>', ']]>', $text_out);
$text_out = strip_tags($text_out);
return substr($text_out,0,$max_char);

}
}
}
}


and just have the code where ever you want to have

<....?php echo getPageContent(39,65); .....?>
39 is the page ID

and 65 is the character set