Guys!!!Let’s have some fun...here are some questions 4 u based on php. So ready????Here they are:
1. A script is a
a. Program or sequence of instructions that is interpreted or carried out by processor directly
b. Program or sequence of instruction that is interpreted or carried out by another program
c. Program or sequence of instruction that is interpreted or carried out by web server only
d. None of above
2. When compared to the compiled program, scripts run
a. Faster
b. Slower
c. The execution speed is similar
d. All of above
3. PHP is a widely used ……………. scripting language that is especially suited for web development and can be embedded into html
a. Open source general purpose
b. Proprietary general purpose
c. Open source special purpose
d. Proprietary special purpose
Thursday, August 19, 2010
Wednesday, August 18, 2010
PHP and Database
Select Statement:
• So far, we have created a new table and inserted data into that table. In this lesson we will cover the most common MySQL Query that is used to retrieve information from a database.
• The SELECT statement is used to select data from a database.
• Syntax: SELECT column_name(s)FROM table_name
• Example: The following example selects all the data stored in the "Persons" table created in previous lesson.
<?php
$con = mysql_connect("localhost","root","abc123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con);
$result = mysql_query("SELECT * FROM Persons");
while($row = mysql_fetch_array($result))
{
echo $row['FirstName'] . " " . $row['LastName'] ] . " " . $row['Age'];
echo "<br />";
}
mysql_close($con);
?>
• So far, we have created a new table and inserted data into that table. In this lesson we will cover the most common MySQL Query that is used to retrieve information from a database.
• The SELECT statement is used to select data from a database.
• Syntax: SELECT column_name(s)FROM table_name
• Example: The following example selects all the data stored in the "Persons" table created in previous lesson.
<?php
$con = mysql_connect("localhost","root","abc123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con);
$result = mysql_query("SELECT * FROM Persons");
while($row = mysql_fetch_array($result))
{
echo $row['FirstName'] . " " . $row['LastName'] ] . " " . $row['Age'];
echo "<br />";
}
mysql_close($con);
?>
Monday, August 16, 2010
PHP and Database
Create Statement:
• Create a Database:
• The CREATE DATABASE statement is used to create a database in MySQL.
• Syntax: CREATE DATABASE database_name;
• To get PHP to execute the statement above we must use the mysql_query() function.
• mysql_query - Send a MySQL query.
• Description: resource mysql_query ( string query [, resource link_identifier] ).
• mysql_query() sends an unique query (multiple queries are not supported) to the currently active database on the server that's associated with the specified link_identifier.
• Parameters :
• query: A SQL query (The query string should not end with a semicolon).
• link_identifier: The MySQL connection. If the link identifier is not specified, the last link opened by mysql_connect() is assumed. If no such link is found, it will try to create one as if mysql_connect() was called with no arguments. If by chance no connection is found or established, an E_WARNING level warning is generated.
• Return Values:
• For SELECT, SHOW, DESCRIBE or EXPLAIN statements, mysql_query() returns a resource on success, or FALSE error.
• For other type of SQL statements, UPDATE, DELETE, DROP, etc, mysql_query() returns TRUE on success or FALSE on error.
• Create a Database:
• The CREATE DATABASE statement is used to create a database in MySQL.
• Syntax: CREATE DATABASE database_name;
• To get PHP to execute the statement above we must use the mysql_query() function.
• mysql_query - Send a MySQL query.
• Description: resource mysql_query ( string query [, resource link_identifier] ).
• mysql_query() sends an unique query (multiple queries are not supported) to the currently active database on the server that's associated with the specified link_identifier.
• Parameters :
• query: A SQL query (The query string should not end with a semicolon).
• link_identifier: The MySQL connection. If the link identifier is not specified, the last link opened by mysql_connect() is assumed. If no such link is found, it will try to create one as if mysql_connect() was called with no arguments. If by chance no connection is found or established, an E_WARNING level warning is generated.
• Return Values:
• For SELECT, SHOW, DESCRIBE or EXPLAIN statements, mysql_query() returns a resource on success, or FALSE error.
• For other type of SQL statements, UPDATE, DELETE, DROP, etc, mysql_query() returns TRUE on success or FALSE on error.
Saturday, August 14, 2010
PHP and Database
• Its tym 2 add some dynamic content 2 ur website. The best choice for ease-of-use, price and support is the combination of PHP and MySQL.
• MySQL is currently the most popular open source database server in existence.
• So what is a database actually??
• A database is a structure that comes in two flavors: a flat database and a relational database.
• Flat database is a simple database design consisting of one large table instead of several interconnected tables. Called ‘flat’ because of its only two dimensional (data fields and records) structure, these database cannot represent complex data relationships. Also called flat file database or flatform database.
• Whereas, a relational database takes this "flat file" approach several logical steps further, allowing the user to specify information about multiple tables and the relationships between those tables, and often allowing much more declarative control over what rules the data in those tables must obey (constraints). These use language like SQL.
• In a relational structured database there are tables that store data. The columns define which kinds of information will be stored in the table. An individual column must be created for each type of data you wish to store (i.e. Age, Weight, Height).
• On the other hand, a row contains the actual values for these specified columns. Each row will have 1 value for each and every column. For example a table with columns (Name, Age, Weight-lbs) could have a row with the values (Bob, 65, 165).
• MySQL is currently the most popular open source database server in existence.
• So what is a database actually??
• A database is a structure that comes in two flavors: a flat database and a relational database.
• Flat database is a simple database design consisting of one large table instead of several interconnected tables. Called ‘flat’ because of its only two dimensional (data fields and records) structure, these database cannot represent complex data relationships. Also called flat file database or flatform database.
• Whereas, a relational database takes this "flat file" approach several logical steps further, allowing the user to specify information about multiple tables and the relationships between those tables, and often allowing much more declarative control over what rules the data in those tables must obey (constraints). These use language like SQL.
• In a relational structured database there are tables that store data. The columns define which kinds of information will be stored in the table. An individual column must be created for each type of data you wish to store (i.e. Age, Weight, Height).
• On the other hand, a row contains the actual values for these specified columns. Each row will have 1 value for each and every column. For example a table with columns (Name, Age, Weight-lbs) could have a row with the values (Bob, 65, 165).
Tuesday, August 10, 2010
Sessions in PHP
Sessions in PHP
• Hmm....so what are sessions actually????
• A session is a semi-permanent interactive information interchange, also known as a dialogue, a conversation or a meeting, between two or more communicating devices, or between a computer and user.
• A session is set up or established at a certain point in time, and torn down at a later point in time.
• A session is typically, but not always, stateful, meaning that at least one of the communicating parts needs to save information about the session history in order to be able to communicate, as opposed to stateless communication, where the communication consists of independent requests with responses and HTTP communication is stateless.
• why use them???
• As a website becomes more sophisticated, so must the code that backs it. When you get to a stage where your website need to pass along user data from one page to another, it might be time to start thinking about using sessions.
• A normal HTML website will not pass data from one page to another. In other words, all information is forgotten when a new page is loaded. This makes it quite a problem for tasks like a shopping cart, which requires data(the user's selected product) to be remembered from one page to the next.
• PHP session solves this problem by allowing you to store user information on the server for later use (i.e. username, shopping cart items, etc). However, this session information is temporary and is usually deleted very quickly after the user has left the website that uses sessions.
• It is important to ponder if the sessions' temporary storage is applicable to your website. If you require a more permanent storage you will need to find another solution, like a MySQL database.
• Sessions work by creating a unique identification(UID) number for each visitor and storing variables based on this ID. This helps to prevent two users' data from getting confused with one another when visiting the same webpage.
• Note: If you are not experienced with session programming it is not recommended that you use sessions on a website that requires high-security, as there are security holes that take some advanced techniques to plug.
• Hmm....so what are sessions actually????
• A session is a semi-permanent interactive information interchange, also known as a dialogue, a conversation or a meeting, between two or more communicating devices, or between a computer and user.
• A session is set up or established at a certain point in time, and torn down at a later point in time.
• A session is typically, but not always, stateful, meaning that at least one of the communicating parts needs to save information about the session history in order to be able to communicate, as opposed to stateless communication, where the communication consists of independent requests with responses and HTTP communication is stateless.
• why use them???
• As a website becomes more sophisticated, so must the code that backs it. When you get to a stage where your website need to pass along user data from one page to another, it might be time to start thinking about using sessions.
• A normal HTML website will not pass data from one page to another. In other words, all information is forgotten when a new page is loaded. This makes it quite a problem for tasks like a shopping cart, which requires data(the user's selected product) to be remembered from one page to the next.
• PHP session solves this problem by allowing you to store user information on the server for later use (i.e. username, shopping cart items, etc). However, this session information is temporary and is usually deleted very quickly after the user has left the website that uses sessions.
• It is important to ponder if the sessions' temporary storage is applicable to your website. If you require a more permanent storage you will need to find another solution, like a MySQL database.
• Sessions work by creating a unique identification(UID) number for each visitor and storing variables based on this ID. This helps to prevent two users' data from getting confused with one another when visiting the same webpage.
• Note: If you are not experienced with session programming it is not recommended that you use sessions on a website that requires high-security, as there are security holes that take some advanced techniques to plug.
Subscribe to:
Posts (Atom)