func_num_args() function returns the number of parameters/arguments passed to a function in PHP.
difference between include and require?
PMA03:07
Answer: It"s how they handle failures. If the file is not found by require(), it will cause a fatal error and halt the
execution of the script. If the file is not found by include(), a warning will be issued, but execution will
continue.
Use mysqldump to create a copy of the database?
PMA05:25
mysqldump -h mysqlhost -u username -p mydatabasename > tgdbdump.sql
Conditional Functions mysql
PMA05:18
The IF() Function
The first argument is a condition that is evaluated for each
row of the query. The value in the second is returned if the condition is trUE, and the third argument is
returned if it is FALSE.
The following example is a very simple shipping rate
calculator. If the product weight is less than 5 pounds, shipping costs $1.99;
otherwise, it costs $2.99.
mysql> SELECT code, weight, IF(weight < 5, 1.99, 2.99) -> FROM products; +------+--------+------------------------------+ | code | weight | IF(weight <5, 1.99, 2.99) | +------+--------+------------------------------+ | MINI | 1.50 | 1.99 | | MIDI | 4.50 | 1.99 | | MAXI | 8.00 | 2.99 | +------+--------+------------------------------+ 3 rows in set (0.00 sec)
The CASE Statement
The CASE statement is a multiple-valued conditional
construct. Suppose you wanted to set three or more shipping rates based on
weight. This would require a complex series of nested IF()
functions.
The following example uses a CASE statement to
determine the shipping rate based on three different weight bands:
mysql> SELECT code, weight, -> CASE WHEN weight < 2 THEN 1.99 -> WHEN weight < 5 THEN 2.99 -> ELSE 4.99 END as shipping -> FROM products; +------+--------+----------+ | code | weight | shipping | +------+--------+----------+ | MINI | 1.50 | 1.99 | | MIDI | 4.50 | 2.99 | | MAXI | 8.00 | 4.99 | +------+--------+----------+ 3 rows in set (0.00 sec)
Combined Queries-UNION
PMA05:16
Mosy SQL queries contain just one SELECT statement
that can return data from one table, or several tables using a join. The
technique of combining two or more independent queries into a single data set is
usually known as a union or a compound query.
You might want to use this technique to retrieve records from
two tables that have a similar structure in a single query. For instance,
suppose you have archived off some data so that you have a customers table that
contains your current customers and another table called
old_customers.
These tables would have the same structureor at least would
share many common columns if new columns had been added to the customers table
since the archive took place. Therefore, you could perform a query on this table
that takes into account both current and archived customers. This would look
something like the following:
SELECT name, telephone, email FROM customers UNION SELECT name, telephone, email FROM old_customers;
You can also use UNION to perform two different queries on the
same table and combine the two results into a single data set.
mysql> SELECT first_name, last_name -> FROM customer_contacts -> WHERE customer_code = 'SCICORP' -> UNION -> SELECT first_name, last_name -> FROM customer_contacts -> WHERE customer_code = 'PRESINC'; +------------+-----------+ | first_name | last_name | +------------+-----------+ | Albert | Einstein | | Charles | Darwin | | Marie | Curie | | Benjamin | Franklin | | Abraham | Lincoln | | Richard | Nixon | | Franklin | Roosevelt | | Theodore | Roosevelt | +------------+-----------+ 8 rows in set (0.01 sec)
What is SQL Injection?
PMA04:12
SQL Injection is the hacking technique which attempts to pass SQL
commands (statements) through a web application for execution by the
backend database.
it can be prevented by mysql_real_escape_string() function of PHP.
Such features as login pages, support and product request forms, feedback forms, search pages, shopping carts and the general delivery of dynamic content, shape modern websites and provide businesses with the means necessary to communicate with prospects and customers.
it can be prevented by mysql_real_escape_string() function of PHP.
Such features as login pages, support and product request forms, feedback forms, search pages, shopping carts and the general delivery of dynamic content, shape modern websites and provide businesses with the means necessary to communicate with prospects and customers.
keep your session secure php
PMA02:40
- Use SSL when authenticating users or performing sensitive operations.
- Regenerate the session id whenever the security level changes (such as logging in). You can even regenerate the session id every request if you wish.
- Have sessions time out
- Don't use register globals
- Store authentication details on the server. That is, don't send details such as username in the cookie.
- Check the
$_SERVER['HTTP_USER_AGENT']
. This adds a small barrier to session hijacking. You can also check the IP address. But this causes problems for users that have changing IP address due to load balancing on multiple internet connections etc (which is the case in our environment here). - Lock down access to the sessions on the file system or use custom session handling
- For sensitive operations consider requiring logged in users to provide their authenication details again.
send images to mail box
PMA02:32
<?php
$message = "<html><head></head><body>";
$message .= "<img src='http://exp.com/images/logo.jpg' alt='' />
</body>
</html>";
$cleanedFrom="admin@abfdgd.com";
$headers = "From: $cleanedFrom";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$to="snmurty99@gmail.com";
$subject="sample images";
mail($to, $subject, $message, $headers);
?>