Php

Autocomplete using jQuery, PHP and MySQL

Autocomplete using jQuery, PHP and MySQL

Database, Jquery, Php
Autocomplete is a basic mandatory functionality in any web development. It will help user to find the correct item just with partial name/some letters of the item which they know about the item.     Import the below scripts and CSS's: [plain] <script type="text/javascript" src="http://code.jquery.com/jquery-2.1.1.min.js"></script> <script type="text/javascript" src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.11.0/jquery-ui.min.js"></script> <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css" type="text/css" /> <link rel="stylesheet" href="//maxcdn....

Google Book Search API to search Related Books with Keywords

Php
Google Book Search API to search Related Books with Keywords: Searching the books with user keyword is became very easy with google books/google book search API. Book search can be done using author or publisher or book title or isbn etc., using google book search API.     You need to create Goolgle API Credential to use the google books API: Go to this link, https://console.developers.google.com/project/   Create a New Project:   Create a New key => Browser Key:       Replace the generated key in the below program, [php] $google_key ="ENTER_YOUR_GOOGLE_API_KEY"; $google_books_url = "https://www.googleapis.com/books/v1/volumes?q=$searchTerm&orderB=relevance&key...

How to use property file in php ?

Php
How to use property file in php ? What is Property file ? Property file in php will have the .ini extension. which will be used generally for the constant informations like website_url, filepaths and key, value mappings etc. Extension: Its a .ini extension. Sample Property file: prop.ini: Idea=12 Airtel=2 Aircel=1 (or) Idea=12; Airtel=2; Aircel=1; PHP Code to get the prop(ini file) values by its key: [php] <?php $ini_array = parse_ini_file("prop.ini"); $propKey = 'Idea'; echo $ini_array[$propKey]; ?> [/php] Output: 12 Download Source code: Php Property File Source code Please feel free to post your queries/comments..... Php Recommended Books:

[Solved] Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at

Errors and solutions, Php
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at session_start() should be used first line in the php code and php code should exist even above the html tag. session1.php: [php] <html> <?php session_start(); $check = 0; if(isset($_SESSION['var1'])){ $check =1; } ?> <head> </head> <body> <?php if($check==1){ ?> With Session <?php }else{ ?> Without Session. <a href="session2.php">Click here to initate the session</a> <?php } ?> </body> </html> [/php] session2.php: [php] <?php session_start(); $_SESSION['var1']='Javadomain.in'; header ("Location: session1.php"); ?> [/php] O...

PHP Hello world Cron Job in Cpanel (step by step explained)

Php
PHP Hello world Cron Job in Cpanel (step by step explained) Step 1: Login to cpanel and click the Cron Jobs. Step 2: Choose the Cron Job (repetions like every 5 minutes, one hour once, one day once etc..,) Step 3: Give the command like this in the above image, [plain gutter="false"]php -q -f /home/YOUR_LOGIN_NAME/public_html/croncheck.php[/plain] Step 4: croncheck.php contains simple echo, [php gutter="false"] <?php echo "cron job running"; ?> [/php] Step 5: We will be getting the email if we have configured the cron email in the Cron Jobs. For the above program we will get email with the subject, [plain gutter="false"]"Cron Job running"[/plain] PHP Recommended Books:

How to check whether the variable is present or not in php ?

Php
Checking variable presence in php: isset(): isset() is a function used to identify whether the variable is present or not in the php programs. It will take the variable name as argument and returns the boolean results(true/false). PHP Program to check variable presence in the code: [php gutter="false"] <?php $var1 = 10; if(isset($var1)){ echo '$var1 Variable is there'."\n"; }else{ echo '$var1 Variable is not there'."\n"; } if(isset($var2)){ echo '$var2 Variable is there'."\n"; }else{ echo '$var2 Variable is not there'."\n"; } ?> [/php] Output: [plain gutter="false"] $var1 Variable is there $var2 Variable is not there [/plain] Note: In the program var1 is exist, so its printed variable var1 is there ...

Equal Vs Identical difference in php Example

Php
Equal (==) vs Identical (===): Equal (==): To compare the value of the variable. Eg: [php gutter="false"] <?php $a = 10; $b = 10; if("$a" == $b){ echo "Its Equal - string and Integer value are Equal\n"; } if($a == $b){ echo "Its also Equal - Integer and Integer value are equal"; } ?> [/php] Output: [plain gutter="false"] Its Equal - string and Integer value are Equal Its also Equal - Integer and Integer value are equal [/plain] Identical (===): To compare the value of the variable as well as type of the variable Eg: [php gutter="false"] <?php $a = 10; $b = 10; if("$a" === $b){ echo "Its Equal - string and Integer value are Equal\n"; } if($a === $b){ echo "Its also Equal - I...

PHP Reference Operator(&) with example

Php
Reference operator: Reference operator(&) introduced in php 4.0 version. Why we need reference operator ? Consider this is the scenario, We have variable a and b. Variable a value assigned to variable b. If we are changing the variable a value frequently after the value assignment to variable b, it will not be reflected. To overcome the above issue reference operator introduced in php. Sample PHP Program: [without Reference operator] [php gutter="false"] <?php $a = 5; $b = $a; $a = 10; echo $b; ?> [/php] Output: [plain gutter="false"] 5 [/plain] Here we have assigned a variable a value to variable b. But after the assignment variable a value has been changed from 5 to 10. But if you print b variable, we are getting the old assigned value (5) only. ...

$ vs $$ in php examples

Php
$ vs $$ in php: $ can be used for variables. $$ can be used to assign the values to the existing variables values. Sample PHP Program: [php gutter="false"] <?php $val = 'value1'; // Assigning values to value1 variable directly using $$. $$val = 10; echo "Printing val variable ::: ".$val; echo "\n"; echo "Printing val variables value(here value1) :::".$$val; echo "\n"; echo "Priting value1 variable value (value assigned using $$) :::". $value1; ?> [/php] Output: [plain gutter="false"] Printing val variable ::: value1 Printing val variables value(here value1) :::10 Priting value1 variable value (value assigned using $$) :::10 [/plain] PHP Recommended Books:

Single quote vs Double quote in php with examples

Php
Almost all PHP programmers will get confusion on this atleast one time in their development carrier, Single Quote: 1. Values will not be interpreted (\n will be displayed as \n only instead of printing in new line). 2. Values will not be evalued ($val will be printed $val only, instead of printing the $val variable value). Eg: Sample Program: [php gutter="false"] <?php $val = 2; echo '$val'; echo "\n"; echo 'hello \n world'; ?> [/php] Output: [plain gutter="0"] $val hello \n world [/plain] Double Quote: 1. Values will be interpreted (\n will be printing in new line). 2. Values will be evalued ($val will be printing the $val variable value). Eg: [php gutter="false"] <?php $val = 2; echo "$val"; echo "\n"; echo ...