It start new or resume existing session
<?php
session_start();
$_SESSION[‘lan’]=”PHP Code”;
echo $_SESSION[‘lan’] ;
session_destroy();
?>
It start new or resume existing session
<?php
session_start();
$_SESSION[‘lan’]=”PHP Code”;
echo $_SESSION[‘lan’] ;
session_destroy();
?>
Sessions are global variable that can store values and will be accessible throughout the site .The applications that uses session are user login,cart etc . Session values are stored in the server and it will will have reference to a an session id which will be generated when some one call session_start() and will be stored in the local machine
Once the session id created , this id will be passed to the server along with request and with the help of this the code can fect the values stored in the server .
Session values can be managed with the help of $_SESSION[] .
Session can be destroyed using the function session_destroy()
Session values will get destroyed if the browser is closed .
Example
<?php
session_start();
$_SESSION[‘lan’]=”PHP Code”;
echo $_SESSION[‘lan’] ;
session_destroy();
?>
<?php
$ip = “173.0.52.150”;
if(preg_match(“/^(d{1,3}).(d{1,3}).(d{1,3}).(d{1,3})$/”,$ip)) {
$parts=explode(“.”,$ip);
foreach($parts as $value){
if(intval($value)>255 || intval($value)<0)
echo “Invalid”;
}
echo “Valid IP address”;
}
?>
<?php
preg_match( “/c.*?.*?.*?z/”, “phpcodez.com”, $result );
if(count($result))
print_r($result);
?>
<?php
preg_match( “/c.*?.*?.*?z/”, “phpcodez.com”, $result );
if(count($result))
print_r($result);
?>
<?php
header(“Content-type: application/vnd.ms-word”);
header(“Content-Disposition: attachment;Filename=test.doc”);
echo “phpcodez”;
?>
SQL LEN() returns the length of the value in a text field.
Syntaxt
SELECT LEN(column_name) FROM table_name
SQL FULL JOIN return rows when there is a match in one of the tables
Syntax
SELECT * FROM table_name1 FULL JOIN table_name2
ON table_name1.column_name=table_name2.column_name
MySQL Table – users
|+—-+——+
| id | name |
+—-+——+
| 1 | AAAA |
| 2 | BBBB |
| 3 | CCCC |
| 4 | DDDD |
| 5 | EEEE |
+—-+——+
MySQL Table – Orders
+—–+—–+——–+
| oid | uid | items |
+—–+—–+——–+
| 1 | 1 | Pen |
| 2 | 2 | Watch |
| 3 | 3 | shoe |
| 4 | 4 | mobile |
+—–+—–+——–+
Example
mysql> SELECT u.name,o.items FROM users as u FULL JOIN orders as o ON u.id=o.uid ;
+——+——–+
| name | items |
+——+——–+
| AAAA | Pen |
| BBBB | Watch |
| CCCC | shoe |
| DDDD | mobile |
+——+——–+
4 rows in set (0.00 sec)
The SELECT statement is used to select data from a database.
SQL SELECT Syntax
SELECT field_names FROM table_name
Field name should be seperated with comma .
If you want the data from all the fields ,then just use “ * “
MySQL Table – users
+—-+——+
| id | name |
+—-+——+
| 1 | PHP |
| 2 | JS |
| 3 | HTML |
| 4 | JSP |
| 5 | ASP |
+—-+——+
Example
mysql> select * from users;
+—-+——+
| id | name |
+—-+——+
| 1 | PHP |
| 2 | PHP |
| 3 | PHP |
| 4 | PHP |
| 5 | PHP |
+—-+——+
mysql> select name from users;
+——+
| name |
+——+
| PHP |
| JS |
| HTML |
| JSP |
| ASP |
+——+
MySQL is a relational database management system (RDBMS)that runs as a server providing multi-user access to a number of databases. It is named after co-founder Michael Widenius’ daughter, My. The SQL phrase stands for Structured Query Language.
The MySQL development project has made its source code available under the terms of the GNU General Public License, as well as under a variety of proprietary agreements. MySQL was owned and sponsored by a single for-profit firm, the Swedish company MySQL AB, now owned by Oracle Corporation.
Free-software-open source projects that require a full-featured database management system often use MySQL. For commercial use, several paid editions are available, and offer additional functionality.