Monday, 8 December 2014
Wednesday, 10 September 2014
MySQL Data Types
In MySQL there are three main types : text, number, and Date/Time types.
Text types:
Data type | Description |
---|---|
CHAR(size) | Holds a fixed length string (can contain letters, numbers, and special characters). The fixed size is specified in parenthesis. Can store up to 255 characters |
VARCHAR(size) | Holds a variable length string (can contain letters, numbers, and special characters). The maximum size is specified in parenthesis. Can store up to 255 characters. Note: If you put a greater value than 255 it will be converted to a TEXT type |
TINYTEXT | Holds a string with a maximum length of 255 characters |
TEXT | Holds a string with a maximum length of 65,535 characters |
BLOB | For BLOBs (Binary Large OBjects). Holds up to 65,535 bytes of data |
MEDIUMTEXT | Holds a string with a maximum length of 16,777,215 characters |
MEDIUMBLOB | For BLOBs (Binary Large OBjects). Holds up to 16,777,215 bytes of data |
LONGTEXT | Holds a string with a maximum length of 4,294,967,295 characters |
LONGBLOB | For BLOBs (Binary Large OBjects). Holds up to 4,294,967,295 bytes of data |
ENUM(x,y,z,etc.) | Let you enter a list of possible values. You can list up to 65535 values in an ENUM list. If a value is inserted that is not in the list, a blank value will be inserted.Note: The values are sorted in the order you enter them. You enter the possible values in this format: ENUM('X','Y','Z') |
SET | Similar to ENUM except that SET may contain up to 64 list items and can store more than one choice |
Number types:
Data type | Description |
---|---|
TINYINT(size) | -128 to 127 normal. 0 to 255 UNSIGNED*. The maximum number of digits may be specified in parenthesis |
SMALLINT(size) | -32768 to 32767 normal. 0 to 65535 UNSIGNED*. The maximum number of digits may be specified in parenthesis |
MEDIUMINT(size) | -8388608 to 8388607 normal. 0 to 16777215 UNSIGNED*. The maximum number of digits may be specified in parenthesis |
INT(size) | -2147483648 to 2147483647 normal. 0 to 4294967295 UNSIGNED*. The maximum number of digits may be specified in parenthesis |
BIGINT(size) | -9223372036854775808 to 9223372036854775807 normal. 0 to 18446744073709551615 UNSIGNED*. The maximum number of digits may be specified in parenthesis |
FLOAT(size,d) | A small number with a floating decimal point. The maximum number of digits may be specified in the size parameter. The maximum number of digits to the right of the decimal point is specified in the d parameter |
DOUBLE(size,d) | A large number with a floating decimal point. The maximum number of digits may be specified in the size parameter. The maximum number of digits to the right of the decimal point is specified in the d parameter |
DECIMAL(size,d) | A DOUBLE stored as a string , allowing for a fixed decimal point. The maximum number of digits may be specified in the size parameter. The maximum number of digits to the right of the decimal point is specified in the d parameter |
Thursday, 4 September 2014
Display different div click in php
####################### Just Copy And Past #######################
<div id="nav">
<a href="#content1">Show 1</a>
<a href="#content2">Show 2</a>
</div>
<div id="content1" class="toggle" style="display:none">Show 1</div>
<div id="content2" class="toggle" style="display:none">Show 2</div>
$("#nav a").click(function(e){
e.preventDefault();
$(".toggle").hide();
var toShow = $(this).attr('href');
$(toShow).show();
});
</script>
<div id="nav">
<a href="#content1">Show 1</a>
<a href="#content2">Show 2</a>
</div>
<div id="content1" class="toggle" style="display:none">Show 1</div>
<div id="content2" class="toggle" style="display:none">Show 2</div>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js'></script>
<script type="text/javascript">$("#nav a").click(function(e){
e.preventDefault();
$(".toggle").hide();
var toShow = $(this).attr('href');
$(toShow).show();
});
</script>
Tuesday, 24 June 2014
JavaScript validation required field border changed
/////////////////////////////////////////Just Copy Past///////////////////////////////
<form name= "reg" id="reg" method="POST" action="http://www.qualityzoneinfotech.com/" onsubmit="return validate()">
<input id="first" name="first" type="text" value="" placeholder="first"><br />
<input id="email" name="email" type="text" value="" placeholder="email"><br />
<textarea id="message" name="message" placeholder="message" ></textarea><br />
<input type="submit"></button>
</form>
<script type="text/javascript">
function validate(){
var formIsValid = true;
var first=document.forms["reg"]["first"];
if(first.value == null || first.value == ""){
first.style.borderColor = "red";
formIsValid = false;
}
var email=document.forms["reg"]["email"];
if(email.value == null || email.value == ""){
email.style.borderColor = "red";
formIsValid = false;
}
var message=document.forms["reg"]["message"];
if(message.value == null || message.value == ""){
message.style.borderColor = "red";
formIsValid = false;
}
return formIsValid;
}
</script>
<form name= "reg" id="reg" method="POST" action="http://www.qualityzoneinfotech.com/" onsubmit="return validate()">
<input id="first" name="first" type="text" value="" placeholder="first"><br />
<input id="email" name="email" type="text" value="" placeholder="email"><br />
<textarea id="message" name="message" placeholder="message" ></textarea><br />
<input type="submit"></button>
</form>
<script type="text/javascript">
function validate(){
var formIsValid = true;
var first=document.forms["reg"]["first"];
if(first.value == null || first.value == ""){
first.style.borderColor = "red";
formIsValid = false;
}
var email=document.forms["reg"]["email"];
if(email.value == null || email.value == ""){
email.style.borderColor = "red";
formIsValid = false;
}
var message=document.forms["reg"]["message"];
if(message.value == null || message.value == ""){
message.style.borderColor = "red";
formIsValid = false;
}
return formIsValid;
}
</script>
PoPup code in JavaScript for PHP
""""""""""""""""""" Just Copy And Past""""""""""""""""""""""""""
<style type="text/css">
/* popup DIV-Styles*/
#popup {
display:none; /* Hide the DIV */
position:fixed;
_position:absolute; /* hack for internet explorer 6 */
height:300px;
width:600px;
background:#FFFFFF;
left: 300px;
top: 150px;
z-index:100; /* Layering ( on-top of others), if you have lots of layers: I just maximized, you can change it yourself */
margin-left: 15px;
/* additional features, can be omitted */
border:1px solid #0000CC;
padding:15px;
font-size:15px;
-moz-box-shadow: 0 0 5px #ff0000;
-webkit-box-shadow: 0 0 5px #ff0000;
box-shadow: 0 0 5px #ff0000;
}
#main {
background:#6699FF; /*Sample*/
width:100%;
height:100%;
}
a{
cursor: pointer;
text-decoration:none;
}
/* This is for the positioning of the Close Link */
#popupBoxClose {
font-size:20px;
line-height:15px;
right:5px;
top:5px;
position:absolute;
color:#6fa5e2;
font-weight:500;
}
</style>
<script src="http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready( function() {
// When site loaded, load the Popupbox First
loadPopupBox();
$('#popupBoxClose').click( function() {
unloadPopupBox();
});
$('#main').click( function() {
unloadPopupBox();
});
function unloadPopupBox() { // TO Unload the Popupbox
$('#popup').fadeOut("slow");
$("#main").css({ // this is just for style
"opacity": "1"
});
}
function loadPopupBox() { // To Load the Popupbox
$('#popup').fadeIn("slow");
$("#main").css({ // this is just for style
"opacity": "0.3"
});
}
});
</script>
<html>
<head>
<title>Quality Zone Infotech POPUPBOX </title>
</head>
<body>
<div id="popup"> <!-- OUR PopupBox DIV-->
<span style="font-size:15px; color:#3333FF;">My Popup Is Working Fine Thanks Quality Zone Infotech</span>
</h1>
<a href="http://www.qualityzoneinfotech.com/" id="popupBoxClose">close</a>
</div>
<div id="main"> <!-- Main Page -->
<h1>Thanks Quality Zone Infoech</h1>
</div>
</body>
</html>
<style type="text/css">
/* popup DIV-Styles*/
#popup {
display:none; /* Hide the DIV */
position:fixed;
_position:absolute; /* hack for internet explorer 6 */
height:300px;
width:600px;
background:#FFFFFF;
left: 300px;
top: 150px;
z-index:100; /* Layering ( on-top of others), if you have lots of layers: I just maximized, you can change it yourself */
margin-left: 15px;
/* additional features, can be omitted */
border:1px solid #0000CC;
padding:15px;
font-size:15px;
-moz-box-shadow: 0 0 5px #ff0000;
-webkit-box-shadow: 0 0 5px #ff0000;
box-shadow: 0 0 5px #ff0000;
}
#main {
background:#6699FF; /*Sample*/
width:100%;
height:100%;
}
a{
cursor: pointer;
text-decoration:none;
}
/* This is for the positioning of the Close Link */
#popupBoxClose {
font-size:20px;
line-height:15px;
right:5px;
top:5px;
position:absolute;
color:#6fa5e2;
font-weight:500;
}
</style>
<script src="http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready( function() {
// When site loaded, load the Popupbox First
loadPopupBox();
$('#popupBoxClose').click( function() {
unloadPopupBox();
});
$('#main').click( function() {
unloadPopupBox();
});
function unloadPopupBox() { // TO Unload the Popupbox
$('#popup').fadeOut("slow");
$("#main").css({ // this is just for style
"opacity": "1"
});
}
function loadPopupBox() { // To Load the Popupbox
$('#popup').fadeIn("slow");
$("#main").css({ // this is just for style
"opacity": "0.3"
});
}
});
</script>
<html>
<head>
<title>Quality Zone Infotech POPUPBOX </title>
</head>
<body>
<div id="popup"> <!-- OUR PopupBox DIV-->
<span style="font-size:15px; color:#3333FF;">My Popup Is Working Fine Thanks Quality Zone Infotech</span>
</h1>
<a href="http://www.qualityzoneinfotech.com/" id="popupBoxClose">close</a>
</div>
<div id="main"> <!-- Main Page -->
<h1>Thanks Quality Zone Infoech</h1>
</div>
</body>
</html>
Sunday, 15 June 2014
Display Message in Popup in php
<?php
if($status == 1) { echo '<script>alert("Thanks for submiting your query. We will get back to you in next 24 hours");</script>'; } else{ echo '<script>alert("Meassage has not submitted!");</script>'; } ?>
Tuesday, 3 June 2014
Remove powered by kunena forum
Write this line in your css file
/*powerd by kunena hide*/
#Kunena + div{display:none !important}
After that Press Ctr+F5
if it will help you then comment must
/*powerd by kunena hide*/
#Kunena + div{display:none !important}
After that Press Ctr+F5
if it will help you then comment must
Monday, 2 June 2014
Sunday, 25 May 2014
Code for social Likes and share
-----: Just past this code and use it :------
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-like" data-href="https://www.facebook.com/qualityzoneinfotech" data-width="50px" data-layout="standard" data-action="like" data-show-faces="true" data-share="true"></div>
<script language="javascript">
function shinra_fb_count( $url_or_id ) {
/* url or id (for optional validation) */
if( is_int( $url_or_id ) ) $url = 'http://graph.facebook.com/' . $url_or_id;
else $url = 'http://graph.facebook.com/' . $url_or_id;
/* get json */
$json = json_decode( file_get_contents( $url ), false );
/* has likes or shares? */
if( isset( $json->likes ) ) return (int) $json->likes;
elseif( isset( $json->shares ) ) return (int) $json->shares;
return 0; // otherwise zed
}
</script>
<div id="social"><!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style ">
<a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>
<a class="addthis_button_tweet"></a>
<a class="addthis_button_pinterest_pinit"></a>
<a class="addthis_counter addthis_pill_style"></a>
</div>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=xa-51572bbd79133ec6"></script>
<!-- AddThis Button END -->
</div>
Saturday, 24 May 2014
Php code for number of hits on web page
<?php
// start at the top of the page since we start a session
session_name('hit_counter');
session_start();
//
$fn = 'hits_counter.txt';
$hits = 0;
// read current hits
if (($hits = file_get_contents($fn)) === false)
{
$hits = 0;
}
// write one more hit
if (!isset($_SESSION['page_visited_already']))
{
if (($fp = @fopen($fn, 'w')) !== false)
{
if (flock($fp, LOCK_EX))
{
$hits++;
fwrite($fp, $hits, strlen($hits));
flock($fp, LOCK_UN);
$_SESSION['page_visited_already'] = 1;
}
fclose($fp);
}
}
?>
<!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=utf-8" />
<title>PHP Hit Counter Code</title>
</head>
<body>
<p>Hits of page</p>
<div class="counter">
<p>This page has <span><?=$hits;?></span> hits</p>
</div>
</body>
</html>
// start at the top of the page since we start a session
session_name('hit_counter');
session_start();
//
$fn = 'hits_counter.txt';
$hits = 0;
// read current hits
if (($hits = file_get_contents($fn)) === false)
{
$hits = 0;
}
// write one more hit
if (!isset($_SESSION['page_visited_already']))
{
if (($fp = @fopen($fn, 'w')) !== false)
{
if (flock($fp, LOCK_EX))
{
$hits++;
fwrite($fp, $hits, strlen($hits));
flock($fp, LOCK_UN);
$_SESSION['page_visited_already'] = 1;
}
fclose($fp);
}
}
?>
<!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=utf-8" />
<title>PHP Hit Counter Code</title>
</head>
<body>
<p>Hits of page</p>
<div class="counter">
<p>This page has <span><?=$hits;?></span> hits</p>
</div>
</body>
</html>
How to uninstall module in Joomla 2.5
Its is very simple task to uninstall module , plugins, and components follow these steps..
If you want to uninstall an module,component and plugin to go in Joomla administrator area -> Extensions -> Extension Manager.
Open the Manage tab. Select Module,plugin or component from the Select Type drop-down menu. check the checkbox which you want to uninstall and Find the Uninstall icon in the upper right Joomla 2.5 menu and click on it to completely remove the chosen module.
Remember Joomla 2.5 core modules can not be uninstalled.
Saturday, 10 May 2014
How To Write htaccess File in php
RewriteRule
!\.(html|php)$ - [S=5]
RewriteRule
^.*-(vf12|vf13|vf5|vf35|vf1|vf10|vf33|vf8).+$ - [S=1]
Options
+FollowSymLinks
RewriteEngine
On
RewriteBase
/
Options
+FollowSymLinks
RewriteEngine
On
RewriteBase
/
RewriteCond
%{HTTP_HOST} !^www\.askapache\.com$ [NC]
RewriteRule
^(.*)$ http://www.askapache.com/$1 [R=301,L]
Sometimes your rewrites cause
infinite loops, stop it with one of these rewrite code snippets.
RewriteCond
%{REQUEST_URI} ^/(stats/|missing\.html|failed_auth\.html|error/).* [NC]
RewriteRule
.* - [L]
RewriteCond
%{ENV:REDIRECT_STATUS} 200
RewriteRule
.* - [L]
This is probably my favorite, and I
use it on every site I work on. It allows me to update my javascript and css
files in my visitors cache's simply by naming them differently in the html, on
the server they stay the same name. This rewrites all files for /zap/j/anything-anynumber.js
to /zap/j/anything.js and /zap/c/anything-anynumber.css to /zap/c/anything.css
RewriteRule
^zap/(j|c)/([a-z]+)-([0-9]+)\.(js|css)$ /zap/$1/$2.$4 [L]
When you use flash on your site and
you properly supply a link to download flash that shows up for non-flash aware
browsers, it is nice to use a shortcut to keep your code clean and your
external links to a minimum. This code allows me to link to site.com/getflash/ for non-flash aware browsers.
RewriteRule
^getflash/?$
http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash
[NC,L,R=307]
On many sites, the page will be
displayed for both page.html and page.html?anything=anything, which hurts your
SEO with duplicate content. An easy way to fix this issue is to redirect
external requests containing a query string to the same uri without the
query_string.
RewriteCond
%{THE_REQUEST} ^GET /.*;.* HTTP/
RewriteCond
%{QUERY_STRING} !^$
RewriteRule
.* http://www.askapache.com%{REQUEST_URI}? [R=301,L]
This .htaccess rewrite example
invisibly rewrites requests for all Adobe pdf files to be handled by /cgi-bin/pdf-script.php
RewriteRule
^(.+)\.pdf$
/cgi-bin/pdf-script.php?file=$1.pdf [L,NC,QSA]
For sites using multiviews or with
multiple language capabilities, it is nice to be able to send the correct
language automatically based on the clients preferred language.
RewriteCond
%{HTTP:Accept-Language} ^.*(de|es|fr|it|ja|ru|en).*$ [NC]
RewriteRule
^(.*)$ - [env=prefer-language:%1]
This allows access to all files by
php fopen, but denies anyone else.
RewriteEngine
On
RewriteBase
/
RewriteCond
%{THE_REQUEST} ^.+$ [NC]
RewriteRule
.* - [F,L]
If you are looking for ways to block
or deny specific requests/visitors, then you should definately read Blacklist with mod_rewrite. I give it a 10/10
This can be very handy if you want
to serve media files or special downloads but only through a php proxy script.
RewriteEngine
On
RewriteBase
/
RewriteCond
%{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+)/.* HTTP [NC]
RewriteRule
.* - [F,L]
Options
+FollowSymLinks
RewriteEngine
On
RewriteBase
/
RewriteCond
%{HTTP_HOST} !^askapache\.com$ [NC]
RewriteRule
^(.*)$ http://askapache.com/$1 [R=301,L]
Uses a RewriteCond Directive
to check QUERY_STRING for passkey, if it doesn't find it it redirects all
requests for anything in the /logged-in/ directory to the /login.php script.
RewriteEngine
On
RewriteBase
/
RewriteCond
%{QUERY_STRING} !passkey
RewriteRule
^/logged-in/(.*)$ /login.php [L]
If the QUERY_STRING has any value at
all besides blank than the?at the end of /login.php? tells mod_rewrite to remove the
QUERY_STRING from login.php and redirect.
RewriteEngine
On
RewriteBase
/
RewriteCond
%{QUERY_STRING} .
RewriteRule
^login\.php /login.php? [L]
An error message related to this isRequest
exceeded the limit of 10 internal redirects due to probable configuration
error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use
'LogLevel debug' to get a backtrace.or
you may seeRequest exceeded the limit,probable configuration error,Use 'LogLevel debug' to get a
backtrace, orUse
'LimitInternalRecursion' to increase the limit if necessary
RewriteCond
%{ENV:REDIRECT_STATUS} 200
RewriteRule
.* - [L]
RewriteRule
^(.*)\.php$ /$1.html [R=301,L]
Redirects all files that end in
.html to be served from filename.php so it looks like all your pages are .html
but really they are .php
RewriteRule
^(.*)\.html$ $1.php [R=301,L]
Options
+FollowSymLinks
RewriteEngine
On
RewriteBase
/
#
If the hour is 16 (4 PM) Then deny all access
RewriteCond
%{TIME_HOUR} ^16$
RewriteRule
^.*$ - [F,L]
Converts all underscores
"_" in urls to hyphens "-" for SEO benefits... See the full article
for more info.
Options
+FollowSymLinks
RewriteEngine
On
RewriteBase
/
RewriteRule
!\.(html|php)$ - [S=4]
RewriteRule
^([^_]*)_([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4-$5 [E=uscor:Yes]
RewriteRule
^([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4 [E=uscor:Yes]
RewriteRule
^([^_]*)_([^_]*)_(.*)$ $1-$2-$3 [E=uscor:Yes]
RewriteRule
^([^_]*)_(.*)$ $1-$2 [E=uscor:Yes]
RewriteCond
%{ENV:uscor} ^Yes$
RewriteRule
(.*) http://d.com/$1 [R=301,L]
Options
+FollowSymLinks
RewriteEngine
On
RewriteBase
/
RewriteCond
%{HTTP_HOST} !^www\.[a-z-]+\.[a-z]{2,6} [NC]
RewriteCond
%{HTTP_HOST} ([a-z-]+\.[a-z]{2,6})$
[NC]
RewriteRule
^/(.*)$ http://%1/$1 [R=301,L]
Friday, 28 February 2014
Learn Wordpress admin panel
WordPress is web software you can use to create a beautiful website or blog. We like to say that WordPress is both free and priceless at the same time.
The latest stable release of WordPress (Version 3.8.1) is available in two formats from the links to your right. If you have no idea what to do with this download, we recommend signing up with one of our web hosting partners that offers a one-click install of WordPress or getting a free account on WordPress.com.
Wednesday, 26 February 2014
Fibonacci Series in php
<?php
$a = 1;
$b = 2;
$term = 10;
$i = 0;
echo $a." ".$b." ";
for($i; $i<10 ; $i++)
{
$c = $b + $a;
echo $c." ";
$a = $b;
$b = $c;
}
?>
Output: 1 2 3 5 8 13 21 34 55 89 144 233 377
$a = 1;
$b = 2;
$term = 10;
$i = 0;
echo $a." ".$b." ";
for($i; $i<10 ; $i++)
{
$c = $b + $a;
echo $c." ";
$a = $b;
$b = $c;
}
?>
Output: 1 2 3 5 8 13 21 34 55 89 144 233 377
Wednesday, 5 February 2014
How To Print Stars in PHP
Q1. Print star in descending order.
<?php
for($i=0;$i<=5;$i++){
for($j=5-$i;$j>=1;$j--){
echo "* ";
}
echo "<br>";
}
?>
Output:
*****
****
***
**
*
Q2. print star in ascending order.
<?php
for($i=1;$i<=5;$i++){
for($j=5;$j>=0;$j--){
if($j<$i){
echo "* ";
}
}echo "<br>";
}
?>
Output:
*
**
***
****
*****
<?php
for($i=0;$i<=5;$i++){
for($j=5-$i;$j>=1;$j--){
echo "* ";
}
echo "<br>";
}
?>
Output:
*****
****
***
**
*
Q2. print star in ascending order.
<?php
for($i=1;$i<=5;$i++){
for($j=5;$j>=0;$j--){
if($j<$i){
echo "* ";
}
}echo "<br>";
}
?>
Output:
*
**
***
****
*****
Tuesday, 4 February 2014
Mysql Queries With Examples
Q1. Find 2nd highest salary in sql
Ans: SELECT salary FROM table_name ORDER BY salary DESC LIMIT 1 , 1;
Ans: SELECT salary FROM table_name ORDER BY salary DESC LIMIT 1 , 1;
Thursday, 23 January 2014
Find Factorial No
<?php
$num=5;
$fact = 1;
for($i = 1; $i <= $num ;$i++)
$fact = $fact * $i;
echo $fact;
?>
Output: 5*4*3*2*1= 120
$num=5;
$fact = 1;
for($i = 1; $i <= $num ;$i++)
$fact = $fact * $i;
echo $fact;
?>
Output: 5*4*3*2*1= 120
Find Prime No in PHP
<?php
$num =23;
for( $j = 2; $j <= $num; $j++ )
{
for( $k = 2; $k < $j; $k++ )
{
if( $j % $k == 0 )
{
break;
}
}
if( $k == $j )
echo "$j".",";
}
?>
Output: 2,3,5,7,11,13,17,19,23,
$num =23;
for( $j = 2; $j <= $num; $j++ )
{
for( $k = 2; $k < $j; $k++ )
{
if( $j % $k == 0 )
{
break;
}
}
if( $k == $j )
echo "$j".",";
}
?>
Output: 2,3,5,7,11,13,17,19,23,
Monday, 20 January 2014
PHP Interview Questions With Answers
Q1. Who is the father of PHP and explain the changes
in PHP versions?
Ans: Rasmus Lerdorf in 1994
Q2. How many ways you can retrieve the date in the result set of mysql using PHP?
Ans: We can do it by 4 Ways
1. mysql_fetch_row. ,
Q4. What is the difference between mysql_fetch_object and mysql_fetch_array?
Q9. How can we know the count/number of elements of an array?
Ans: Rasmus Lerdorf in 1994
Q2. How many ways you can retrieve the date in the result set of mysql using PHP?
Ans: We can do it by 4 Ways
1. mysql_fetch_row. ,
2. mysql_fetch_array ,
3. mysql_fetch_object
4. mysql_fetch_assoc
4. mysql_fetch_assoc
Q3. How can we create a database using php and mysql?
Ans: <?php
$query =mysql_query( "CREATE DATABASE phpcake");
?>Q4. What is the difference between mysql_fetch_object and mysql_fetch_array?
Ans: 1. object is returned, instead of an array
2. In this you can only access the data by the field names
Q5. What are the differences between Get and post methods.
Ans: GET Method have some limit like only 2Kb data able to send for request But in POST method unlimited data can we send.
Q6. What are the differences between require and include?
Ans: Include and require used to include a file but If included file not found Include send Warning where as Require send Fatal Error .
Q7. What is the difference between the functions unlink and unset?
Ans: unlink() deletes the given file from the file system.
unset() makes a variable undefined.
Q8. What are the different functions in sorting an array?
Ans: Sort(), arsort(),asort(), ksort(),natsort(), natcasesort(),rsort(), usort(),array_multisort(), and uksort().
Q7. What is the difference between the functions unlink and unset?
Ans: unlink() deletes the given file from the file system.
unset() makes a variable undefined.
Q8. What are the different functions in sorting an array?
Ans: Sort(), arsort(),asort(), ksort(),natsort(), natcasesort(),rsort(), usort(),array_multisort(), and uksort().
Ans: a) sizeof($urarray) This function is an alias of count()
b) count($urarray)
Q10. How can we find the number of rows in a table using MySQL?
b) count($urarray)
Q10. How can we find the number of rows in a table using MySQL?
Ans: SELECT COUNT(*) FROM table_name;
Q11. How can we know the number of days between two given dates using PHP?
Ans: $date1 = date("Y-m-d");
$date2 = "2006-08-15";
$days = (strtotime($date1) - strtotime($date2)) / (60 * 60 * 24);
Q14. What is the difference between explode and cookies php..?
$date2 = "2006-08-15";
$days = (strtotime($date1) - strtotime($date2)) / (60 * 60 * 24);
Q12. what are magic methods?
Ans: Magic methods are the members functions that is available to all the instance of class Magic methods always starts with "__". Eg. __construct All magic methods needs to be declared as public To use magic method they should be defined within the class or program scope Various Magic Methods used in PHP 5 are: __construct() __destruct() __set() __get() __call() __toString() __sleep() __wakeup() __isset() __unset() __autoload() __clone()
Ans: Magic methods are the members functions that is available to all the instance of class Magic methods always starts with "__". Eg. __construct All magic methods needs to be declared as public To use magic method they should be defined within the class or program scope Various Magic Methods used in PHP 5 are: __construct() __destruct() __set() __get() __call() __toString() __sleep() __wakeup() __isset() __unset() __autoload() __clone()
Q13. Email function in PHP?
Ans: <?php $to = qualityzoneinfotech@gmail.com;
$subject = 'Qualityzoneinfotech.';
$body = "<p><strong>Heading...</strong> <br />
<strong>Custmer Name:</strong> <?php $name ;?> </p><br />
<strong>Custmer Email:</strong> <?php $email; ?>l </p><br />
<strong>Order Date:</strong> <?php date; ?>";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Time2employment.com <qualityzoneinfotech@gmail.com>' . "\r\n";
$headers .= 'Cc: qualityzoneinfotech@gmail.com' . "\r\n";
mail($to, $subject, $body, $headers);
?>
Q14. What is the difference between session and cookies php..?
Ans : A session is always stored in the server. You lose all the session data once you close your browser, as every time you re-open your browser, a new session starts for any website.
A cookie is stored in the client’s browser.You can store almost anything in a browser cookie.
Q14. What is the difference between session and cookies php..?
Ans : A session is always stored in the server. You lose all the session data once you close your browser, as every time you re-open your browser, a new session starts for any website.
A cookie is stored in the client’s browser.You can store almost anything in a browser cookie.
Q14. What is the difference between explode and cookies php..?
Ans : Explode : its used to skip the any sign or blank space in a string.
$str = "Quality zone Infotech PVT LTD.";
print_r (explode(" ",$str));
Implode : Its used for insert any character or space in string.
<?php
$arr = array('Hello','Quality','Zone','Infotech!');
echo implode(" ",$arr);
?>
$str = "Quality zone Infotech PVT LTD.";
print_r (explode(" ",$str));
Implode : Its used for insert any character or space in string.
<?php
$arr = array('Hello','Quality','Zone','Infotech!');
echo implode(" ",$arr);
?>
How to limit an excerpt in wordpress
Limit the number of words in excerpt without plugins...
Put the following piece of code in your templates functions.php file:
<?php
function string_limit_words($string, $word_limit)
{
$words = explode(' ', $string, ($word_limit + 1));
if(count($words) > $word_limit)
array_pop($words);
return implode(' ', $words);
}
?>
Next, put the following piece of code in your template where you want to display the excerpt:
<?php
$excerpt = get_the_excerpt();
echo string_limit_words($excerpt,25);
?>
Where 25 is the number of words to display.
Put the following piece of code in your templates functions.php file:
<?php
function string_limit_words($string, $word_limit)
{
$words = explode(' ', $string, ($word_limit + 1));
if(count($words) > $word_limit)
array_pop($words);
return implode(' ', $words);
}
?>
Next, put the following piece of code in your template where you want to display the excerpt:
<?php
$excerpt = get_the_excerpt();
echo string_limit_words($excerpt,25);
?>
Where 25 is the number of words to display.
Payment gateway integration in joomla by jumi
That is the code for EBS payment gateway integration in joomla by jumi
<?
$secretKey='103e8d197683e80a7dbba3b9eb9beb14';
$account_id='14014';
$amount='112';
$refrence_no='123456';
$return_url="http://www.qualityzoneinfotech.com/services/website-development.html";
$mode='LIVE';
$string = "$secretKey|$account_id|$amount|$refrence_no|$return_url|$mode";
$secure_hash = md5($string);
$profile = JUserHelper::getProfile($user->id);
?>
<form method="post" action="https://secure.ebs.in/pg/ma/sale/pay" name="frmTransaction" id="frmTransaction" onSubmit="return validate()">
<input name="account_id" type="hidden" value="<? echo $account_id; ?>">
<input name="return_url" type="hidden" size="60" value="<? echo $return_url; ?>" />
<input name="mode" type="hidden" size="60" value="<? echo $mode; ?>" />
<input name="reference_no" type="hidden" value="<? echo $refrence_no; ?>" />
<input name="amount" type="hidden" value="<? echo $amount; ?>"/>
<input name="description" type="hidden" value="XYZ pvt ltd" />
<input name="name" type="hidden" maxlength="55" value="<? echo $name=$user->name; ?>" />
<input name="address" type="hidden" maxlength="55" value="<?php echo $profile->profile['region'];?>" />
<input name="city" type="hidden" maxlength="55" value="<?php echo $profile->profile['city'];?>" />
<input name="state" type="hidden" maxlength="55" value="<?php echo $profile->profile['region'];?>" />
<input name="postal_code" type="hidden" maxlength="55" value="<?php echo $profile->profile['postal_code'];?>" />
<input name="country" type="hidden" maxlength="55" value="Ind" />
<input name="phone" type="hidden" maxlength="55" value="<?php echo $profile->profile['phone'];?>" />
<input name="email" type="hidden" size="60" value="<? echo $email=$user->email; ?>" />
<input name="secure_hash" type="hidden" size="60" value="<? echo $secure_hash;?>" />
<input type="submit" name="submit" value="Buy Now">
</form></li>
</ul>
If you want any support so just drop me a mail on website development001@gmail.com
<?
$secretKey='103e8d197683e80a7dbba3b9eb9beb14';
$account_id='14014';
$amount='112';
$refrence_no='123456';
$return_url="http://www.qualityzoneinfotech.com/services/website-development.html";
$mode='LIVE';
$string = "$secretKey|$account_id|$amount|$refrence_no|$return_url|$mode";
$secure_hash = md5($string);
$profile = JUserHelper::getProfile($user->id);
?>
<form method="post" action="https://secure.ebs.in/pg/ma/sale/pay" name="frmTransaction" id="frmTransaction" onSubmit="return validate()">
<input name="account_id" type="hidden" value="<? echo $account_id; ?>">
<input name="return_url" type="hidden" size="60" value="<? echo $return_url; ?>" />
<input name="mode" type="hidden" size="60" value="<? echo $mode; ?>" />
<input name="reference_no" type="hidden" value="<? echo $refrence_no; ?>" />
<input name="amount" type="hidden" value="<? echo $amount; ?>"/>
<input name="description" type="hidden" value="XYZ pvt ltd" />
<input name="name" type="hidden" maxlength="55" value="<? echo $name=$user->name; ?>" />
<input name="address" type="hidden" maxlength="55" value="<?php echo $profile->profile['region'];?>" />
<input name="city" type="hidden" maxlength="55" value="<?php echo $profile->profile['city'];?>" />
<input name="state" type="hidden" maxlength="55" value="<?php echo $profile->profile['region'];?>" />
<input name="postal_code" type="hidden" maxlength="55" value="<?php echo $profile->profile['postal_code'];?>" />
<input name="country" type="hidden" maxlength="55" value="Ind" />
<input name="phone" type="hidden" maxlength="55" value="<?php echo $profile->profile['phone'];?>" />
<input name="email" type="hidden" size="60" value="<? echo $email=$user->email; ?>" />
<input name="secure_hash" type="hidden" size="60" value="<? echo $secure_hash;?>" />
<input type="submit" name="submit" value="Buy Now">
</form></li>
</ul>
If you want any support so just drop me a mail on website development001@gmail.com
Subscribe to:
Posts (Atom)