A Basic HTML5 Template

As you learn HTML5 and add new techniques to your toolbox, you’re likely going
to want to build yourself a blueprint, or boilerplate, from which you can begin all
your HTML5-based projects. In fact, you’ve probably already done something similar
for your existing XHTML or HTML 4.0 projects. We encourage this, and you
may also consider using one of the many online sources that provide a basic HTML5
starting point for you.
In this project, however, we want to build our code from scratch and explain each
piece as we go along. Of course, it would be impossible for even the most fantastical
and unwieldy sample site we could dream up to include every new element or
technique, so we’ll also explain some new features that don’t fit into the project.
This way, you’ll be familiar with a wide set of options when deciding how to build
your HTML5 and CSS3 websites and web apps, so you’ll be able to use this book
as a quick reference for a number of techniques.


<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>The HTML5 Herald</title>
<meta name="description" content="The HTML5 Herald">
<meta name="author" content="SitePoint">
<link rel="stylesheet" href="css/styles.css?v=1.0">
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js">
</script>
<![endif]-->
</head>
<body>
1

What is a cookie , explaing ?

Cookie is use to store the temporary data in browser memory, We can store data in cookies using setcookie('name','value','time');
we can use that rule for simple cookie, this value will store in the browser memory. If the browser is closed the cookie value will be deleted. Another way to store data in cookie file for long time:
persistent cookie using that way we can store data for long time in the user system.

How can we find the number of rows in a MySQL table?

By Mysql

SELECT COUNT(*) FROM table_name;

How to prevent hijacking in PHP?

 Make Error_reporting to E_ALL so that all variables will be intialized before using them.
 Make practice of using htmlentities(), strip_tags(), utf8_decode() and addslashes() for filtering malicious data in php
 Make practice of using mysql_escape_string() in mysql.

What is difference between mysql_fetch_array(),mysql_fetch_row() and mysql_fetch_object() ?

mysql_fetch_array():: fetches a result row as a associated array, numeric array

mysql_fetch_object: Fetaches a result row as object.

mysql_fetch_row::fetches a result row as array

SELECTING DATA IN PHP

You frequently select data in a MySQL table using PHP. Selecting data through a PHP program
using a MySQL command takes four steps:
1. Make a connection to the database.
2. Create a safe query with the command.
3. Run the query.
4. Read the results.
The following code makes the connection and creates a safe query. Rather than just running the
query, use it as the right side of an assignment. This creates a mysqli_result object that you use to
read the results via methods in the result object. This example takes each row, one at a time,
and puts it into an associative array.


<?php
define(“MYSQLUSER”, “php24sql”);
define(“MYSQLPASS”, “hJQV8RTe5t”);
define(“HOSTNAME”, “localhost”);
define(“MYSQLDB”, “test”);
// Make connection to database
$connection = @new mysqli(HOSTNAME, MYSQLUSER, MYSQLPASS, MYSQLDB);
if ($connection->connect_error) {
die(‘Connect Error: ‘ . $connection->connect_error);
} else {
echo ‘Successful connection to MySQL <br />’;
// Set up the query
$query = “SELECT * FROM ‘table1‘ “
. “ WHERE ‘code‘ = 15”
. “ ORDER BY ‘description‘ ASC “
;
// Run the query
$result_obj = ‘’;
$result_obj = $connection->query($query);
// Read the results
// loop through the result object, row by row
// reading each row into an associative array
while($result = $result_obj->fetch_array(MYSQLI_ASSOC)) {
// display the array
print_r($result);
echo ‘<br />’;
}
}

// Read the results
// loop through the results, row by row
// reading each row into an associative array
while($result = $result_obj->fetch_array(MYSQLI_ASSOC)) {
// collect the array
$item[] = $result;
}
// print array when done
echo ‘<pre>’;
print_r($item);
echo ‘</pre>’;


The example prints out the array









fetch_array(MYSQLI_ASSOC): This returns an associative array. Loop through to get all the
rows. Same as fetch_assoc().
‰ fetch_array(MYSQLI_NUM): This returns a numeric array. Loop through to get all the rows.
Same as fetch_row().
‰ fetch_array(MYSQLI_BOTH): This returns both an associative array and a numeric array
with the same data. Loop through to get all the rows. This is the default if no type is
specifi ed.
‰ fetch_all(MYSQLI_ASSOC): This returns all the rows as an associative array.
‰ fetch_all(MYSQLI_NUM): This returns all the rows as a numeric array.
‰ fetch_all(MYSQLI_BOTH): This returns all the rows both as an associative array and a
numeric array with the same data.
‰ fetch_object($class_name): This returns an object of the row. Loop through to get all
the rows. If you give it a class name, it uses that class to create the object. If there is no class
name it will create a stdClass object, which is a predefi ned class.

Optimizing for Both Facebook and Search Engines

You’re probably familiar with search engine optimization (SEO) tactics for improving your website’s
search rankings in Google and other major search engines. But have you thought about how to incorporate
social media into your search strategy?
Facebook can be a valuable asset for search results. The volume of content and variety of places to add
keyword-rich content can help you attract new Page members on Facebook, while providing more natural
search results
Facebook is indexed by search engines and also has deals with Google
and Bing to display social search results that include posts from your friends.
Facebook’s search is not always the greatest at displaying results, but the site’s working on it.
Counteract its shortcomings with some rockstar SEO to ensure that people looking for your name or
service can find you. Misspellings are especially important to account for on Facebook.
In the more general natural-search realm, a well-optimized Facebook Page can help you overtake
a competitor by providing a second set of Pages (in addition to your own website) to display on the
search results page. This can also be helpful when you’re looking to do some reputation management.
A Facebook Page can also give you the opportunity to add a few more keywords that didn’t work as
well on your website..

Developing a Facebook Content Strategy

Given the restrictions Facebook places on Page design, content is the easiest—and often most
effective—
way to differentiate yourself from competitors. Facebook’s power lies in its huge number
of users, but this also creates a high volume of posts. To reach these potential customers or brand
enthusiasts, your content must stand apart from the rest. Because content is a core piece of a successful
Facebook marketing campaign, this chapter explores ways you can create and optimize it for
Page members, while at the same time improving your placement in both Facebook and natural web
searches.

Competing with Other Content on Facebook
The average Facebook user has 130 friends and is connected to 80 community Pages, Groups, and
Events. Yet this is only a fraction of the 900 million people, places, and things that he could interact with
on Facebook

Considering the more than 30 billion pieces of content being shared across
the site each month, you can understand clearly why content is a key factor in your Facebook marketing
strategy. Obviously, there’s a lot that the average user is seeing on a daily basis. But this average user
also creates about 90 pieces of content every month—posting links to news stories or blog posts, writing
notes, uploading to photo albums, creating Events, writing on friends’ Walls, and more.

Since Facebook imposes so many design restrictions, content is the best way to market yourself to
potential Page members (and future customers), as well as to keep current Page members and customers
engaged and entertained. On the other hand, you must also combat the fatigue many users feel at
seeing a never-ending stream of their friends’ lunch orders, random thoughts, and recent likes.

What Is a Session?

It is stored at server side because PHP is server side scripting language

Session is stored on server side because how much time page will execute it doesn't depend on client it depends on server. Server decide the session of each page ..thats why session is stored on server side

Session is to store as the server side value
method $_session start('id');
and cookie is store the validation of client side

How do you define a constant in php?

by define() directive,
like define (“MYCONSTANT”, 500);