You can access / display any webpage through the following code:
<?php
echo DownloadUrl('http://www.imjan.com'); // Type Website URL to download
function DownloadUrl($Url){
// is curl installed?
if (!function_exists('curl_init')){
die('CURL is not installed!');
}
// create a new curl resource
$ch = curl_init();
/*
Here you find more options for curl:
http://www.php.net/curl_setopt
*/
// set URL to download
curl_setopt($ch, CURLOPT_URL, $Url);
// set referer:
curl_setopt($ch, CURLOPT_REFERER, "http://www.google.com/");
// user agent:
curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");
// remove header? 0 = yes, 1 = no
curl_setopt($ch, CURLOPT_HEADER, 0);
// should curl return or print the data? true = return, false = print
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// timeout in seconds
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
// download the given URL, and return output
$output = curl_exec($ch);
// close the curl resource, and free system resources
curl_close($ch);
// print output
return $output;
}
?>
Organic traffic gives you real user plus more business for any niche. There are several ways to choose the best keywords for your website to increase your organic traffic of your website. If you follow the following steps you can get more traffic than any other website.
* Be specific with niche and find your main competitors?
* Fetch their main keywords, and browse google.com/sktool fill the form and select your keywords (Note: Do not select keywords have low competition).
* Search these selected keywords in different search engines and check out who is your main competitor with that particular keyword.
* List them all and fetch their keywords. and adjust your product pages according to their product page in short i am saying you to copy your competitor for each product page.
* Optimize these pages, do link building and directory submission your will see your new website will start getting hits from different Geo graphic locations with different keywords, that traffic means increase in your sales.
* Remember do not copy your competitor text (Product description), Write your own keyword rich product description.
he CHAR and VARCHAR types are similar, but differ in the way they are stored and retrieved. As of MySQL 5.0.3, they also differ in maximum length and in whether trailing spaces are retained.
The CHAR and VARCHAR types are declared with a length that indicates the maximum number of characters you want to store. For example, CHAR(30) can hold up to 30 characters.
both myisam and innodb are storange enginein sql.
innodb support transaction, foreign key while myisam not
support transaction.
Other differences are :
1. innodb requires more RAM than mysiam
2. myisam relies on OS for caching while innodb caches with
in the engine itself.
3. Most preffered is innodb because
- Transaction safe
-It has commit, rollback, and crash recovery capabailities
- Innodb is designed for maximum performance when processing
large volumes of data.
InnoDB: Row level locking, Transaction support, forgin key
constrant and crash recovery.
MyISAM: Much more conservate approach to disk space
management each MyISAM table store in a separate file. in
MyISAM memory and space usage, full text indexing support,
table based locking, bulk insert capabilities and speed are
plus factor but crushes recovery would be the horror story.
As general approach, if you have a more reads use MyISAM and
if you have a more update use InnoDB.
Stored routines, that is, stored procedures and functions. A stored function is used much like a built-in function. you invoke it in an expression and it returns a value during expression evaluation. A stored procedure is invoked using the CALL statement. A procedure does not have a return value but can modify its parameters for later inspection by the caller. It can also generate result sets to be returned to the client program.
Triggers. A trigger is a named database object that is associated with a table and that is activated when a particular event occurs for the table, such as an insert or update.
Events. An event is a task that runs according to schedule.
Views are stored queries that when invoked produce a result set. A view acts as a virtual table.
Each stored program contains a body that consists of an SQL statement. This statement may be a compound statement made up of several statements separated by semicolon (;) characters. For example, the following stored procedure has a body made up of a BEGIN … END block that contains a SET statement and a REPEAT loop that itself contains another SET statement:
CREATE PROCEDURE dorepeat(p1 INT)
BEGIN
SET @x = 0;
REPEAT SET @x = @x + 1; UNTIL @x > p1 END REPEAT;
END
If you use the mysql client program to define a stored program that contains the semicolon characters within its definition, a problem arises. By default, mysql itself recognizes semicolon as a statement delimiter, so you must redefine the delimiter temporarily to cause mysql to pass the entire stored program definition to the server.
To redefine the mysql delimiter, use the delimiter command. The following example shows how to do this for the dorepeat() procedure just shown. The delimiter is changed to // to enable the entire definition to be passed to the server as a single statement, and then restored to ; before invoking the procedure. This allows the ; delimiter used in the procedure body to be passed through to the server rather than being interpreted by mysql itself.
mysql> delimiter //
mysql> CREATE PROCEDURE dorepeat(p1 INT)
-> BEGIN
-> SET @x = 0;
-> REPEAT SET @x = @x + 1; UNTIL @x > p1 END REPEAT;
-> END
-> //
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT @x;
+——+
| @x |
+——+
| 1001 |
+——+
1 row in set (0.00 sec)
You can redefine the delimiter to a string other than //, and the delimiter can consist of a single character or multiple characters. You should avoid the use of the backslash (“\”) character because that is the escape character for MySQL.
The following is an example of a function that takes a parameter, performs an operation using an SQL function, and returns the result. In this case, it is unnecessary to use delimiter because the function definition contains no internal ; statement delimiters:
Stored routines (procedures and functions) are supported in MySQL 5.1. A stored routine is a set of SQL statements that can be stored in the server. Once this has been done, clients don’t need to keep reissuing the individual statements but can refer to the stored routine instead.
Stored routines require the proc table in the mysql database. This table is created during the MySQL 5.1 installation procedure. If you are upgrading to MySQL 5.1 from an earlier version, be sure to update your grant tables to make sure that the proc table exists.
MySQL Enterprise. For expert advice on using stored procedures and functions subscribe to the MySQL Enterprise Monitor. For more information, see http://www.mysql.com/products/enterprise/advisors.html.
Stored routines can be particularly useful in certain situations:
* When multiple client applications are written in different languages or work on different platforms, but need to perform the same database operations.
* When security is paramount. Banks, for example, use stored procedures and functions for all common operations. This provides a consistent and secure environment, and routines can ensure that each operation is properly logged. In such a setup, applications and users would have no access to the database tables directly, but can only execute specific stored routines.
Stored routines can provide improved performance because less information needs to be sent between the server and the client. The tradeoff is that this does increase the load on the database server because more of the work is done on the server side and less is done on the client (application) side. Consider this if many client machines (such as Web servers) are serviced by only one or a few database servers.
Stored routines also allow you to have libraries of functions in the database server. This is a feature shared by modern application languages that allow such design internally (for example, by using classes). Using these client application language features is beneficial for the programmer even outside the scope of database use.
MySQL follows the SQL:2003 syntax for stored routines, which is also used by IBM’s DB2.
The MySQL implementation of stored routines is still in progress. All syntax described here is supported and any limitations and extensions are documented where appropriate.
MySQL 5.0 New Features: Stored Procedures (By Peter Gulutzan)
Introduction
This 67 page guide is for long-time MySQL users who want to know “what’s new” in version 5. The short answer is “stored procedures, triggers, views, information_schema”. The long answer is the MySQL 5.0 New Features series, and this book is the first in the series.
What I’m hoping to do is make this look like a hands-on session where you, as if you’re working it out yourself on your keyboard, can walk through sample problems.
To do this, I’ll go through each little item, building up slowly. By the end, I’ll be showing larger routines that do something useful, something that you might have thought was tough. A Definition and an Example
A stored procedure is a procedure (like a subprogram in a regular computing language) that is stored (in the database). Correctly speaking, MySQL supports “routines” and there are two kinds of routines: stored procedures which you call, or functions whose return values you use in other SQL statements the same way that you use pre-installed MySQL functions like pi(). I’ll use the word “stored procedures” more frequently than “routines” because it’s what we’ve used in the past, and what people expect us to use.
A stored procedure has a name, a parameter list, and an SQL statement, which can contain many more SQL statements. There is new syntax for local variables, error handling, loop control, and IF conditions. Here is an example of a statement that creates a stored procedure.
CREATE PROCEDURE procedure1 /* name */
(IN parameter1 INTEGER) /* parameters */
BEGIN /* start of block */
DECLARE variable1 CHAR(10); /* variables */
IF parameter1 = 17 THEN /* start of IF */
SET variable1 = ‘birds’; /* assignment */
ELSE
SET variable1 = ‘beasts’; /* assignment */
END IF; /* end of IF */
INSERT INTO table1 VALUES (variable1); /* statement */
END /* end of block */
What I’m going to do is explain in detail all the things you can do with stored procedures. We’ll also get into another new database object, triggers, because there is a tendency to associate triggers with stored procedures.
Why Stored Procedures
Stored procedures are something new for MySQL, so naturally you’ll approach them with some caution. After all, there’s no track record, no large body of user experience that proves they’re the way to go. Nevertheless, you should start to think now about moving your code out of where it is now (an application host program, a UDF, a script), and into a stored procedure. The reasons for using procedures are compelling.
Stored procedures are proven technology! Yes, they are new in MySQL, but the same functionality exists in other DBMSs, and often precisely the same syntax too. So there are concepts that you can steal, there are people with experience whom you can consult or hire, there is third-party documentation (books or web pages) that you can read.
Stored procedures are fast! Well, we can’t prove that for MySQL yet, and everyone’s experience will vary. What we can say is that the MySQL server takes some advantage of caching, just as prepared statements do. There is no compilation, so an SQL stored procedure won’t work as quickly as a procedure written with an external language such as C. The main speed gain comes from reduction of network traffic. If you have a repetitive task that requires checking, looping, multiple statements, and no user interaction, do it with a single call to a procedure that’s stored on the server. Then there won’t be messages going back and forth between server and client, for every step of the task.
Stored procedures are components! Suppose that you change your host language — no problem, the logic is in the database not the application.
Stored procedures are portable! When you write your stored procedure in SQL, you know that it will run on every platform that MySQL runs on, without obliging you to install an additional runtime-environment package, or set permissions for program execution in the operating system, or deploy different packages if you have different computer types. That’s the advantage of writing in SQL rather than in an external language like Java or C or PHP. Don’t get me wrong about this: I know there are sometimes excellent reasons to support external-language routines, they just lack this particular advantage.
Stored procedures are stored! If you write a procedure with the right naming conventions, for example saying chequing_withdrawal for a bank transaction, then people who want to know about chequing can find your procedure. It’s always available as ’source code’ in the database itself. And it makes sense to link the data with the processes that operate on the data, as you might have heard in your programming-theory classes.
Stored procedures are migratory! MySQL adheres fairly closely to the SQL:2003 standard. Others (DB2, Mimer) also adhere. Others (Oracle, SQL Server) don’t adhere but I’ll be providing tips and tools that make it easier to take code written for another DBMS and plunking it into MySQL.