How can remove duplicate values from an array php

You can use array_unique function in php


<?php
$value 
= array("test","test1","test2","test"); $value array_unique($value); print_r($value); ?> 


Outputs:

Array
(
[0] => test
[1] => test1
[2] => test2
)

how can get current time in mysql

how can get current time in mysql


NOW() using in query u can get current time...


<?php
$update 
mysql_query("UPDATE test SET lastlogin = NOW() WHERE username = 'test'"); ?>

How can check value exit in an array

How can check value exit in an array


 in_array function can use to check value exit in an array


example
<?php
$value1 
= array("test","test1","test2","test4"); $new_value1="test1";
if (
in_array($new_value1,$value1)) { echo "$newvalue is already in the array!"; } ?> 

php shorthand operater

php shorthand operater (.=)

concatenation  example
$test.=$tes1;
same like above
$test=$test.$tes1;

how can make mysql support all language

how can make mysql support all language

ALTER DATABASE MyDb CHARACTER SET utf8;

interpolation with curly braces in php


interpolation with curly braces in php


$test="test2";
Ex:$plan="test1 {$test} test3";

strings in php

strings in php 


String are Sequence of characters that can be treated as a unit assigned to variables,simple specify  php code is to enclose it in quotes

string in php whether single or double

ex:$my='php single string';
$my1="double quotes"

full Text search in mysql

full Text search in mysql 



MySQL supported FULLTEXT indexes 3.23.23.VARCHAR and TEXT Columns that have been indexed with FULLTEXT can be used with special SQL statements that perform the full text search in MySQL.

ALTER TABLE test_tab ADD FULLTEXT(title, body);
Once you have done  FULLTEXT index, you can search it using MATCH and AGAINST statements. For example:

SELECT * FROM test_tab
WHERE MATCH ((title, body) AGAINST ('body content');
The result of this query is automatically sorted by relevancy.

some case not support fulltext index because Full-text indexes can be used only with MyISAM

php ternary operator

php ternary operator


evaluate experssion 1 if experssion one is true evaluate experession 2 otherwise return expression 3

syntax ternary operater
experssion-1?
experssion-2 :
experssion-3

file uploading code in php

file uploading code in php


How to HTML form will work



<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="fileupload" id="file" />
<input type="submit" name="submit" value="Upload file" />
</form>
 PHP  file code

<?php
if ($_FILES["fileupload"]["error"] > 0)
{
echo "Error code when upload: " . $_FILES["fileupload"]["error"] . "<br />";
}
else
{
echo "Upload file name : " . $_FILES["fileupload"]["name"] . "<br />";
echo "Type of the file: " . $_FILES["fileupload"]["type"] . "<br />";
echo "Size of the file in KB: " . ($_FILES["fileupload"]["size"] / 1024) . "<br />";
echo "Stored in temporary folder : " . $_FILES["fileupload"]["tmp_name"];
move_uploaded_file($_FILES["fileupload"]["tmp_name"],"uploads/".$_FILES["file"]["name"]);
}
?>

how can sending email in php

how can sending email in php


mail() function using for email sending in php

<?php
$from="test@gmail.com";
$to="to@gmail.com";
$subject="Test Mail";
$message="Hi ,<br />".
"test mail <br />".
"Thank You";
$headers = "From: $from\r\nContent-type: text/html";
if(mail($to,$subject, $message, $headers))
{
echo "MAIL SENT SUCCESSFULLY";
}
else
{
echo "SOME ISSUE WITH MAIL SENDING in SERVER";
}
?>

how can Adding line break using PHP

how can Adding line break using PHP

 nl2br()



<?php
echo nl2br("test\n php line break");
?>

terminate script in php

php terminating script


exit() ;
die();

break and continue in php

break command exits the innermost loop construct the contains it
continue command skip to the end of current iteration

break command example in php

for($i=0;$i<10;$i++)
{
if($i%2!=0)
break;
print("$i");
}
continue command example


for($i=0;$i<10;$i++)
{
if($i%2!=0)
continue;
print("$i");
}



switch syntax in php

switch syntax in php


swicth(expression)
{
case value1:
stms1
stms2
break;
case 2:
stms1;
break
.
.
.
default
default stms
}



Find Largest number among 3 numbers using switch case in php


<?php 
	    $a = 11; 
	    $b = 2; 
	    $c = 20; 
	    // Swich allows expression 
	    switch($a>$b AND $b>$c){ 
	        case TRUE: echo "$a is bigger"; 
	                   break; 
	        case FALSE: switch($b>$c){ 
	            case TRUE: echo "$b is bigger"; 
	                       break; 
	            case FALSE: echo "$b is bigger"; 
	                        break; 
	        }     
	    } 
	?>

php supported logical operators

php supported logical operators


and
or
||
&&
!

what are printing functions in php

 printing functions in php


print_r() and var_dump

what are difference between echo and print in php

difference between echo and print in php


The two most construct for printing out put  echo and print,the value returned by print will be 1 if printing was successful otherwise returned 0 if unsuccess,echo is a statement and print is function

php escape sequence

php escape sequence


php offers escape sequence characters (/n), u can add new line middle of string

list of php types

php types



Booleans(ture and false)
Integers(numbers with out decimal)
Floating point numbers
Strings
Arrays
Objects
Resources
NULL
Pseudo-types and variables used in this documentation
Type Juggling

what do u mean by php constants

php constants


which have single value throughout their life time....

define(code,111);

how can check value assign or not in php

isset  that test variable assign or not;

how can comments in php code

how can comments in  php code


c language mutliline comments
/*
test
*/
single line comments
//single line comment
#single line comment

what are the include functions in php

what are the include functions in php


include();
include_once();
require();
require_once();

how can set short open tags in php

short open tags in php


<? ?>


you can set up php.ini file to on,short_open tag function enable for  supported php4...

list of web servers support in php

list of web servers support in php


apache,netscape enterprise server ,xitami

server-side scripting

server-side scripting 
server-side scripting is invisible to user,server side scripting mostly web sites to back end like database..php is server side scripting language..

what are client side technologies

client side technologies




css(cascading style sheet),html
client side scripting(javascript,vb script)
java applets
flash animations

how can retrieve data in a result set of mysql using php

1. Using mysql_fetch_row function. This will return an indexed array.
2. Using mysql_fetch_array function. Fetch a result row as an associative array, a numeric array, or both.
3. Using mysql_fetch_object function. This will return the result set as an object.
4. Using mysql_fetch_assoc function. This will Fetch a result row as an associative array

difference between include and include_once in php

difference between include and include_once in php 
Both statements includes and evaluates the specified file during the execution but as the name implies include_once will only include one time.

difference between split() explode() fuction php

 difference between split()  explode() fuction php


Split() is used to split a string using a regular expression, while explode() is used to split a string using another string.

how can redirect pages in php

how can redirect pages in php
header() function.
eg:- header(‘Location:interview_questions.php’);
This must be called before any output is called.


difference between “echo” and “print” in PHP?

difference between “echo” and “print” in PHP?


echo is a constructor and print is a function.echo cannot take arguments but print can take arguments.

$_GET and $_POST variables in php

$_get variables will be displayed in the browser's address bar, when using $_get variables form submission all variable names and values are displayed in the URL. Get variables not suit for large values pass 
 $_POST variables
Information sent from a form with the POST method is invisible to others and has no limits on the amount of information to send.

php loops


  • while 
  • do...while
  • for 
  • foreach

kind of arrays in php


  • Numeric array 
  • Associative array 
  • Multidimensional array

strpos() function in php

strpos function used search character and text with in string,if function found matches will return matches first position otherwise return FALSE.


ex:
<?phpecho strpos("Hello,",",");
?>

it will be return 6

download file in php scripts

download file in php scripts



<?php
$file="playsoft.zip";
$path = $_SERVER['DOCUMENT_ROOT']."/file/";
$fullPath = $path.$current_file;
if ($fd = fopen ($fullPath, "r")) {
    $fsize = filesize($fullPath);
    $path_parts = pathinfo($fullPath);
    $ext = strtolower($path_parts["extension"]);
    switch ($ext) {
        case "pdf":
        header("Content-type: application/zip"); // add here more headers for diff. extensions
        header("Content-Disposition: attachment; filename=\"".$path_parts["basename"]."\""); // use 'attachment' to force a download
        break;
        default;
        header("Content-type: application/octet-stream");
        header("Content-Disposition: filename=\"".$path_parts["basename"]."\"");
    }
    header("Content-length: $fsize");
    header("Cache-control: private"); //use this to open files directly
    while(!feof($fd)) {
        $buffer = fread($fd, 2048);
        echo $buffer;
    }
}
fclose ($fd);
exit;
// example: place this kind of link into the document where the file download is offered:
?>

php register_globals meaning

php register_globals meaning


 a common security problem with PHP is the register_globals setting in PHP's configuration file (php.ini). This setting (which can be either On or Off) tells whether or not to register the contents of the EGPCS (Environment, GET, POST, Cookie, Server) variables as global variables.

what is the difference between http and https

 difference between http and https


The Hypertext Transfer Protocol (HTTP) is a networking protocol for distributed, collaborative, hypermedia information systems.[1] HTTP is the foundation of data communication for the World Wide Web.

Hypertext Transfer Protocol Secure (HTTPS) is a combination of the Hypertext Transfer Protocol (HTTP) with SSL/TLS protocol to provide encrypted communication and secure identification of a network web server.

dropdown field add and remove with jquery

dropdown field add and remove with jquery



<html>
<head>
 <script src="js/jquery.js" type="text/javascript"></script>
 <script type="text/javascript">
  $().ready(function() {
   $('#add').click(function() {
    return !$('#select1 option:selected').remove().appendTo('#select2');
   });
   $('#remove').click(function() {
    return !$('#select2 option:selected').remove().appendTo('#select1');
   });
  });
 </script>

 <style type="text/css">
  a {
   display: block;
   border: 1px solid #aaa;
   text-decoration: none;
   background-color: #fafafa;
   color: #123456;
   margin: 2px;
   clear:both;
  }
  div {
   float:left;
   text-align: center;
   margin: 10px;
  }
  select {
   width: 100px;
   height: 80px;
  }
 </style>

</head>


<body>
 <div>
  <select multiple id="select1">
   <option value="1">Option 1</option>
   <option value="2">Option 2</option>
   <option value="3">Option 3</option>
   <option value="4">Option 4</option>
  </select>
  <a href="#" id="add">add &gt;&gt;</a>
 </div>
 <div>
  <select multiple id="select2"></select>
  <a href="#" id="remove">&lt;&lt; remove</a>
 </div>
</body>
</html>

javascript clear textarea on click

javascript clear textarea on click


<form name="myform">
<textarea name="mytext" cols="30" rows="5"
onclick="document.myform.mytext.value='';">
This text will disappear when you click the textarea with the mouse</textarea>
</form>

select list add and remove php jquery

select list add and remove php jquery demo



<script type="text/javascript" src="http://localhost/online/jquery.js"></script>

<script>
$(function() {
  $(".low input[type='button']").click(function(){
    var arr = $(this).attr("name").split("2");
    var from = arr[0];
    var to = arr[1];
    $("#" + from + " option:selected").each(function(){
      $("#" + to).append($(this).clone());
      $(this).remove();
    });
  });
})
</script>
<div class="container">
    <select name="itemsToChoose" id="left" size="8" multiple="multiple">    
      <option value="1">item1</option>
      <option value="2">item2</option>
      <option value="3">item3</option>
      <option value="4">item4</option>
      <option value="5">item5</option>
    </select>
  </div>

  <div class="low container">
    <input name="left2right" value="add" type="button">
    <input name="right2left" value="remove" type="button">
  </div>

  <div class="container">
    <select name="itemsToAdd" id="right" size="8" multiple="multiple">
    </select>
  </div>









list of effects in jquery

jquery help tips

how can text highlighting in jquery

how can text highlighting in jquery




Text Highlighting Example

jquery animation codes

jquery animation codes


Demo



$(document).ready(function() { 
    $("#clickhere").click(function() { 
        $("#animate1").animate({ 
            height: "20px", 
            width: "10px", 
        }1000); 
        $("#animate2").animate({ 
            height: "50px", 
            width: "500px" 
        }1000); 
    }); 
}); 

what is jquery

what is jquery



jQuery is a JavaScript library that  interact between JavaScript and HTML,jQuery is a JavaScript programming.jQuery is easy to learn.

click mouse hide jquery Text fields

Text fields click mouse hide jquery code

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
</head>
<body>
<input type="text" name="cvv" id="TestDiv">
</body>
<script type="text/javascript">
$(function()
{
$('#TestDiv').click(function()
{
$(this).css({cursor: 'none'});
});
});
</script>
</html>

difference between mysql_connect and pconnect


difference between mysql_connect and pconnect

mysql_connect open a connection to a MySQL Server

mysql_pconnect  open a persistent connection to a MySQL server

difference between mysql_fetch_object and mysql_fetch_array in php

difference between mysql_fetch_object and mysql_fetch_array in php


mysql_fetch_object Fetch a result row as an object,mysql_fetch_arrayFetch a result row as an associative array, a numeric array, or both

php fopen function

php fopen function


$variable=fopen("filename","mode");

unset array

unset array


unset(array name['key']);





simple meaning array in php

simple meaning array  in  php


it consist of key and value,key may be string,numeric...

array example in  php 


$veg=array('r'=>'red','b'=>'blue');



date & year function in php

date & year function in php


With the function date();
eg:
date(F,d,y)-may 28 10

D-week-day
m-month-05
M-month-May
Y-year-2007

what is constant in php

what is constant in php


constant value that never change,constant  can be defind in php using a function define()

eg:
define("moive","Big man");

echo moive;

how can php code comment?

how can php code comment?


 you can use // for single line and /* */ for double line comment

how can sort an array in php

how can sort an array in php



<?php
$myworld = array("a"=>"php","b"=>"learning","c"=>"i'm");
asort($myworld);
print_r($myworld);
?>

Out put will be
Array
(
[c] => i'm
[b] => learning
[a] => php
)

reverse sort an array

reverse sort an array



<?php
$myworld = array("a"=>"everything","b"=>"nothing","c"=>"is");
arsort($myworld);
print_r($myworld);
?>

Which prints this:

Array
(
[b] => nothing
[c] => is
[a] => everything
)

how can reset array values

how can reset array values
<?php
$numbers = array("one","two","three");
next($number);
$thisvalue = current($number); echo "We are now at $thisvalue\n\n";
$first = reset($number);
echo "Back to $first";
?>

array loop in php

array loop in php


<?php
$alphabet 
range("A","Z");
foreach(
$alphabet as $letter) { echo "Ooh look!  The letter $letter\n"; } ?> 

how can output data disply in array

how can output data disply in array


<?php
$value 
= array("one","two","three","four"); print_r($values); ?> 


Outputs:

Array
(
[0] => one
[1] => two
[2] => three
[3] => four
)

two dimensional array in php example

two dimensional array in php example


<?php
$myarray 
= array(); $myarray[0] = array(1,2,3,4); $myarray[1] = array(5,6,7,8); // foreach($myarray as $v) {
foreach(
$v as $myv) {
echo 
"$myv<br>";
}
//prints 1 through 8 on screen ?> 

how can check value exit in array

how can check value exit in array


<?php
$value = array("one","two","three","four");
$new_value = "five";
if (in_array($newvalue,$values)) { echo "$newvalue is already in the array!"; }
?>

main difference between session and cookies in php

main difference between session and cookies in php



main difference between  cookies and session,cookies are stored in the user's browser, and sessions are not. Sessions store in server maches,This difference determines what each is best used for.Cookies can keep information in the user's browser until deleted. If a person has a login and password, this can be set as a cookie in their browser so they do not have to re-login to your website every time they visit. You can store almost anything in a browser cookie. The trouble is that a user can block cookies or delete them at any time. If, for example, your website's shopping cart utilized cookies, and a person had their browser set to block them, then they could not shop at your website.