<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3932080116325211990</id><updated>2024-09-05T19:24:37.778-07:00</updated><category term="Uploading Files with PHP"/><title type='text'>php and mySQL</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://abdulzahra-alameri-php.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3932080116325211990/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://abdulzahra-alameri-php.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Abdul Zahra Al Ameri</name><uri>http://www.blogger.com/profile/16930336258404396441</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXoqssOhhRJKC36bZ0CJtGsg5nuarPlr4IerH_0kFBkpk_YNPxkfIWFoyL0M351NtBRxXjSYguz0iD9Tw-Y_o5aTgyHDQ9hSsr8A78WZ2l8dGvLaFgi4l9UmPR5Vsmk4w/s220/drinktea-medium.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>13</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3932080116325211990.post-820248793145072208</id><published>2011-04-07T22:03:00.000-07:00</published><updated>2011-04-07T22:07:27.814-07:00</updated><title type='text'>MySQL FULLTEXT Searching</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana,arial,helvetica,sans-serif; font-size: 12px;&quot;&gt;Have you ever wanted to search text stored in your database, but couldn&#39;t figure out how to do it efficiently? Are you lazy like me and don&#39;t enjoy maintaining reverse indexes, dictionaries, and word scores? You&#39;re in luck. The release of MySQL 4.0 has made searching text stored in databases available to the masses.&lt;br /&gt;
MySQL has had&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;a href=&quot;http://www.mysql.com/doc/en/Fulltext_Search.html&quot;&gt;FULLTEXT&lt;/a&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;searching in one form or another since version 3.23.23.&lt;code style=&quot;color: #003366;&quot;&gt;FULLTEXT&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;indices in MySQL allow database administrators and programmers to designate any character-based field (&lt;code style=&quot;color: #003366;&quot;&gt;CHAR&lt;/code&gt;,&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;VARCHAR&lt;/code&gt;, or&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;TEXT&lt;/code&gt;) as a&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;FULLTEXT&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;index, which allows for complex text searching against data stored in those fields.&lt;br /&gt;
This feature is not to be confused with the&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;LIKE&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;function in MySQL.&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;LIKE&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;works more along the lines of a regular expression. On the other hand,&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;FULLTEXT&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;indices are fully indexed fields which support stopwords, boolean searches, and relevancy ratings.&lt;br /&gt;
This article assumes you have a working installation of MySQL, a good understanding of how MySQL works, and a basic understanding of web programming (with PHP, Perl, or something similar). Further, this article may not be of any interest to those who are already using&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;FULLTEXT&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;indices in a production environment.&lt;br /&gt;
&lt;h3 style=&quot;font-size: 14px; font-weight: bold;&quot;&gt;How it Works&lt;/h3&gt;The MySQL team has made it extremely easy to add&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;FULLTEXT&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;searching to your tables. They are created much like regular&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;KEY&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;and&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;PRIMARY KEY&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;indices. For the purpose of this article we are going to make a basic blog table, put some data into it, and start searching. Before we get ahead of ourselves we need to create some tables.&lt;br /&gt;
&lt;h4 style=&quot;font-size: 12px; font-weight: bold; margin: 0px; padding: 0px;&quot;&gt;Creating the tables&lt;/h4&gt;&lt;pre style=&quot;background-color: #efefef; clear: both; overflow: auto; padding-bottom: 1.5em; width: 600px;&quot;&gt;&lt;code style=&quot;color: #003366;&quot;&gt;-- The main blog table with our &lt;code style=&quot;color: #003366;&quot;&gt;FULLTEXT&lt;/code&gt; index
-- Nothing extreme here, but you get the idea
CREATE TABLE blog_entries
(
entryID INT(9) UNSIGNED NOT NULL DEFAULT &#39;0&#39; AUTO_INCREMENT,
posted INT(11) UNSIGNED NOT NULL DEFAULT &#39;0&#39;,
categoryID TINYINT(2) UNSIGNED NOT NULL DEFAULT &#39;0&#39;,
title CHAR(255) NOT NULL DEFAULT &#39;&#39;,
entry TEXT NOT NULL DEFAULT &#39;&#39;,
PRIMARY KEY (entryID),
KEY (posted),
KEY (categoryID),
FULLTEXT(title,entry)
);

-- A category table so you can organize your posts and
-- later do some fun searching based on such data.
CREATE TABLE blog_categories
(
categoryID TINYINT(2) UNSIGNED NOT NULL DEFAULT &#39;0&#39; AUTO_INCREMENT,
name CHAR(75) NOT NULL DEFAULT &#39;&#39;,
PRIMARY KEY (categoryID)
);

-- Add some data into your blog
INSERT INTO blog_categories VALUES (1,&#39;Personal&#39;);
INSERT INTO blog_categories VALUES (2,&#39;Work&#39;);
INSERT INTO blog_categories VALUES (3,&#39;Editorials&#39;);

INSERT INTO blog_entries
VALUES (1,
1050942000,
1,
&#39;About miester&#39;,
&#39;I was born in michigan in 1980 in a small town called Adrian.
My mother is named Sue, while my father is named Mike.
They currently live in a small town called East Jordan. On April
27th, 2003 I will graduate from Eastern Michigan University with a
degree in Computer Information Systems.&#39;);

INSERT INTO blog_entries
VALUES (2,
1050942000,
2,
&#39;Today at work&#39;,
&#39;While I was at work today I was having some problems
with the RAID array. It seems that we have a rogue cron script that
is causing problems. When I find out more info I will post it here.&#39;);

INSERT INTO blog_entries
VALUES (3,
1050942000,
1,
&#39;Vacation!&#39;,
&#39;After I graduate I am taking a 2 week vacation. On my
agenda is a trip to Washington DC to see my girlfriend\&#39;s sister
as well as throwing a few discs at the local disc golf course.&#39;);

INSERT INTO blog_entries
VALUES (4,
1050942000,
1,
&#39;Vacation!&#39;,
&#39;I have had a horrible cold for the last few days. Today I drank a
revive vitamin water with 150% of my daily dose of vitamin C. That
should help things out.&#39;);&lt;/code&gt;&lt;/pre&gt;&lt;h4 style=&quot;font-size: 12px; font-weight: bold; margin: 0px; padding: 0px;&quot;&gt;Querying the Data&lt;/h4&gt;Now that we have data in our tables we can begin to query it. There are some restrictions to&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;FULLTEXT&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;searching, which are covered below. You will want to read over the restrictions before you use&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;FULLTEXT&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;indices in a production environment. For now we are going to do a simple query for the word&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;mother&lt;/code&gt;.&lt;br /&gt;
&lt;pre style=&quot;background-color: #efefef; clear: both; overflow: auto; padding-bottom: 1.5em; width: 600px;&quot;&gt;&lt;code style=&quot;color: #003366;&quot;&gt;mysql&amp;gt; SELECT entryID,title
-&amp;gt; FROM blog_entries
-&amp;gt; WHERE MATCH (title,entry) AGAINST(&#39;mother&#39;);
+---------+---------------+
| entryID | title         |
+---------+---------------+
|       1 | About miester |
+---------+---------------+
1 row in set (0.00 sec)&lt;/code&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #efefef; clear: both; overflow: auto; padding-bottom: 1.5em; width: 600px;&quot;&gt;&lt;code style=&quot;color: #003366;&quot;&gt;&lt;iframe align=&quot;left&quot; frameborder=&quot;0&quot; marginheight=&quot;0&quot; marginwidth=&quot;0&quot; scrolling=&quot;no&quot; src=&quot;http://rcm.amazon.com/e/cm?t=imamhussainyoutf-20&amp;amp;o=1&amp;amp;p=8&amp;amp;l=bpl&amp;amp;asins=0596101716&amp;amp;fc1=000000&amp;amp;IS2=1&amp;amp;lt1=_blank&amp;amp;m=amazon&amp;amp;lc1=0000FF&amp;amp;bc1=000000&amp;amp;bg1=FFFFFF&amp;amp;f=ifr&quot; style=&quot;height: 245px; padding-right: 10px; padding-top: 5px; width: 131px;&quot;&gt;&lt;/iframe&gt;&amp;nbsp;&lt;/code&gt;&lt;/pre&gt;There are a few things to note when querying&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;FULLTEXT&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;indices. First, MySQL automatically orders the results by their relevancy rating. Second, queries that are longer than 20 characters will not be sorted. Third, and most importantly, the fields in the&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;MATCH()&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;should be identical to the fields listed in the table&#39;s&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;FULLTEXT&lt;/code&gt;definition.&lt;br /&gt;
All other MySQL syntax works as you&#39;d expect with a&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;FULLTEXT&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;search, meaning you can further limit your search terms. We could search blog entries based on posting date or category. If you let your imagination wander you can think of all sorts of ways to filter your data. Let&#39;s look for blog entries that only appear in the&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;Personal&lt;/code&gt;category and match the term&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;michigan&lt;/code&gt;.&lt;br /&gt;
&lt;pre style=&quot;background-color: #efefef; clear: both; overflow: auto; padding-bottom: 1.5em; width: 600px;&quot;&gt;&lt;code style=&quot;color: #003366;&quot;&gt;mysql&amp;gt; SELECT E.entryID, E.title, C.name
-&amp;gt; FROM blog_entries AS E, blog_categories AS C
-&amp;gt; WHERE E.categoryID=C.categoryID AND
-&amp;gt;       MATCH (E.title, E.entry) AGAINST (&#39;michigan&#39;) AND
-&amp;gt;       E.categoryID=1;
+---------+---------------+----------+
| entryID | title         | name     |
+---------+---------------+----------+
|       1 | About miester | Personal |
+---------+---------------+----------+
1 row in set (0.00 sec)&lt;/code&gt;&lt;/pre&gt;Note that we not only did a join but also filtered the results based on the category. Another thing to note is that&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;FULLLTEXT&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;indices are not case sensitive. If you would like to use MySQL&#39;s relevancy rating in your code you can add the&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;MATCH() ... AGAINST()&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;clause to your&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;SELECT&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;statement as well.&lt;br /&gt;
&lt;pre style=&quot;background-color: #efefef; clear: both; overflow: auto; padding-bottom: 1.5em; width: 600px;&quot;&gt;&lt;code style=&quot;color: #003366;&quot;&gt;mysql&amp;gt; SELECT E.entryID, E.title, C.name,
-&amp;gt;        MATCH (E.title, E.entry) AGAINST (&#39;michigan&#39;) AS score
-&amp;gt; FROM blog_entries AS E, blog_categories AS C
-&amp;gt; WHERE E.categoryID=C.categoryID AND
-&amp;gt;       MATCH (E.title, E.entry) AGAINST (&#39;michigan&#39;) AND
-&amp;gt;       E.categoryID=1;
+---------+---------------+----------+-----------------+
| entryID | title         | name     | score           |
+---------+---------------+----------+-----------------+
|       1 | About miester | Personal | 1.2635315656662 |
+---------+---------------+----------+-----------------+
1 row in set (0.00 sec)&lt;/code&gt;&lt;/pre&gt;&lt;h4 style=&quot;font-size: 12px; font-weight: bold; margin: 0px; padding: 0px;&quot;&gt;Boolean Searches&lt;/h4&gt;Probably the most anticipated feature in MySQL 4.0&#39;s&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;FULLTEXT&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;is the ability to do boolean searches without having to process the query strings. This means you can add&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;+&lt;/code&gt;s and&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;-&lt;/code&gt;s to your queries, along with a host of other commands, and MySQL will interpret them for you.&lt;br /&gt;
&lt;pre style=&quot;background-color: #efefef; clear: both; overflow: auto; padding-bottom: 1.5em; width: 600px;&quot;&gt;&lt;code style=&quot;color: #003366;&quot;&gt;mysql&amp;gt; SELECT E.entryID,E.title,C.name
-&amp;gt; FROM blog_entries AS E, blog_categories AS C
-&amp;gt; WHERE E.categoryID=C.categoryID AND
-&amp;gt;       MATCH (E.title,E.entry) AGAINST (&#39;+vacation -washington&#39; IN BOOLEAN MODE) AND
-&amp;gt;       E.categoryID=1;
+---------+-----------+----------+
| entryID | title     | name     |
+---------+-----------+----------+
|       4 | Vacation! | Personal |
+---------+-----------+----------+
1 row in set (0.00 sec)&lt;/code&gt;&lt;/pre&gt;We have two entries with the word&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;vacation&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;in the title, but since we removed&lt;code style=&quot;color: #003366;&quot;&gt;washington&lt;/code&gt;, entryID 4 does not show up in the result. You can read all about&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;IN BOOLEAN MODE&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;on MySQL&#39;s&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;FULLTEXT&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;a href=&quot;http://www.mysql.com/doc/en/Fulltext_Search.html&quot;&gt;manual page&lt;/a&gt;.&lt;br /&gt;
&lt;table align=&quot;right&quot; border=&quot;1&quot; cellpadding=&quot;10&quot; cellspacing=&quot;2&quot; style=&quot;border-collapse: collapse; border: 1px solid rgb(51, 51, 51); empty-cells: show; font-size: inherit; margin: 8px; width: 140px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td bgcolor=&quot;#ffffff&quot; style=&quot;border-style: none;&quot; valign=&quot;top&quot; width=&quot;140&quot;&gt;&lt;div class=&quot;headline&quot; style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bold;&quot;&gt;Related Reading&lt;/div&gt;&lt;a href=&quot;http://oreilly.com/catalog/9780596004460/index.html?CMP=ILL-4GV796923290&quot;&gt;&lt;img src=&quot;http://covers.oreilly.com/images/9780596004460/cat.gif&quot; style=&quot;border-style: none;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div class=&quot;medlist&quot; style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif; font-size: 12px; margin-bottom: 6px; margin-top: 6px;&quot;&gt;&lt;span class=&quot;title&quot; style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif; font-size: 13px; font-weight: bold;&quot;&gt;&lt;a href=&quot;http://oreilly.com/catalog/9780596004460/index.html&quot;&gt;MySQL Pocket Reference&lt;/a&gt;&lt;/span&gt;&lt;b&gt;&lt;br /&gt;
By&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;a href=&quot;http://www.oreillynet.com/pub/au/429&quot;&gt;George Reese&lt;/a&gt;&lt;/b&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h4 style=&quot;font-size: 12px; font-weight: bold; margin: 0px; padding: 0px;&quot;&gt;Restrictions&lt;/h4&gt;A few restrictions affect MySQL&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;FULLTEXT&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;indices. Some of the default behaviors of these restrictions can be changed in your my.cnf or using the&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;SET&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;command.&lt;br /&gt;
&lt;ul style=&quot;padding-left: 25px;&quot;&gt;&lt;li&gt;&lt;code style=&quot;color: #003366;&quot;&gt;FULLTEXT&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;indices are NOT supported in InnoDB tables.&lt;/li&gt;
&lt;li&gt;MySQL requires that you have at least three rows of data in your result set before it will return any results.&lt;/li&gt;
&lt;li&gt;By default, if a search term appears in more than 50% of the rows then MySQL will not return any results.&lt;/li&gt;
&lt;li&gt;By default, your search query must be at least four characters long and may not exceed 254 characters.&lt;/li&gt;
&lt;li&gt;MySQL has a default&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;stopwords&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;file that has a list of common words (i.e.,&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;the&lt;/code&gt;,&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;that&lt;/code&gt;,&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;has&lt;/code&gt;) which are not returned in your search. In other words, searching for&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;the&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;will return zero rows.&lt;/li&gt;
&lt;li&gt;According to MySQL&#39;s manual, the argument to&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;AGAINST()&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;must be a constant string. In other words, you cannot search for values returned within the query.&lt;/li&gt;
&lt;/ul&gt;&lt;h4 style=&quot;font-size: 12px; font-weight: bold; margin: 0px; padding: 0px;&quot;&gt;Altering&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;FULLTEXT&lt;/code&gt;&#39;s Default Behavior&lt;/h4&gt;There are several ways to alter the default behavior of&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;FULLTEXT&lt;/code&gt;. MySQL has some&lt;a href=&quot;http://www.mysql.com/doc/en/Fulltext_Fine-tuning.html&quot;&gt;tips for fine tuning&lt;/a&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;the&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;FULLTEXT&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;search, but the details are a little sparse. The most common problem is the four character minimum word length on queries. Before we go over that, let&#39;s review the variables associated with the&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;FULLTEXT&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;searching.&lt;br /&gt;
&lt;pre style=&quot;background-color: #efefef; clear: both; overflow: auto; padding-bottom: 1.5em; width: 600px;&quot;&gt;&lt;code style=&quot;color: #003366;&quot;&gt;mysql&amp;gt; SHOW VARIABLES LIKE &#39;ft%&#39;;
+--------------------------+----------------+
| Variable_name            | Value          |
+--------------------------+----------------+
| ft_boolean_syntax        | + -&amp;gt;&amp;lt;()~*:&quot;&quot;&amp;amp;| |
| ft_min_word_len          | 2              |
| ft_max_word_len          | 254            |
| ft_max_word_len_for_sort | 20             |
| ft_stopword_file         | (built-in)     |
+--------------------------+----------------+
5 rows in set (0.00 sec)&lt;/code&gt;&lt;/pre&gt;The variable we wish to change is&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;ft_min_word_len&lt;/code&gt;. According to the manual we should be able to change this via the&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;SET VARIABLE&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;command, but, in reality, this does not work. After asking the mailing list about this problem I was told this had to be specified as a startup option. To change the minimum query string to three characters, start the MySQL server as follows.&lt;br /&gt;
&lt;pre style=&quot;background-color: #efefef; clear: both; overflow: auto; padding-bottom: 1.5em; width: 600px;&quot;&gt;&lt;code style=&quot;color: #003366;&quot;&gt;$ cd /path/to/mysql
$ ./bin/safe_mysqld --user=mysql -O ft_min_word_len=3 &amp;amp;&lt;/code&gt;&lt;/pre&gt;After you have restarted your MySQL server (don&#39;t forget to change your startup scripts) you have to rebuild the&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;FULLTEXT&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;indices. The manual suggests the following command:&lt;br /&gt;
&lt;pre style=&quot;background-color: #efefef; clear: both; overflow: auto; padding-bottom: 1.5em; width: 600px;&quot;&gt;&lt;code style=&quot;color: #003366;&quot;&gt;-- Replace tbl_name with the name of your table
mysql&amp;gt; REPAIR TABLE tbl_name QUICK;&lt;/code&gt;&lt;/pre&gt;After you have rebuilt your indices, you should be able to search with query strings of three or more characters instead of the default four character limit.&lt;br /&gt;
&lt;h3 style=&quot;font-size: 14px; font-weight: bold;&quot;&gt;Having fun with MySQL&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;FULLTEXT&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;Searching&lt;/h3&gt;I&#39;ll save the implementation details for a later article, but here are some interesting ways in which you could use MySQL&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;FULLTEXT&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;searching to finding data on your website more interesting.&lt;br /&gt;
&lt;h4 style=&quot;font-size: 12px; font-weight: bold; margin: 0px; padding: 0px;&quot;&gt;PHP&lt;/h4&gt;A great way to add cross referencing to articles would be to store a query (i.e.,&lt;code style=&quot;color: #003366;&quot;&gt;linux&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;for a post about Debian GNU/Linux) with each article. If an article had a query, PHP could then perform a&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;FULLTEXT&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;search, returning those results as &quot;Related Articles&quot;. Furthermore, you could use PHP to create an advanced search script that allowed users to search the database based on category, criteria, pricing, etc.&lt;br /&gt;
&lt;h4 style=&quot;font-size: 12px; font-weight: bold; margin: 0px; padding: 0px;&quot;&gt;&lt;code style=&quot;color: #003366;&quot;&gt;ispell&lt;/code&gt;&lt;/h4&gt;&lt;code style=&quot;color: #003366;&quot;&gt;ispell&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;is a great tool for open source developers to use to make their applications more user friendly. By adding&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;ispell&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;to your search engine, you can check the spelling of each query, offering alternate queries if the query was spelled wrong. Everyone&#39;s favorite search engine does something similar.&lt;br /&gt;
&lt;h3 style=&quot;font-size: 14px; font-weight: bold;&quot;&gt;Looking towards the Future&lt;/h3&gt;According to the manual, the MySQL team&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;a href=&quot;http://www.mysql.com/doc/en/Fulltext_TODO.html&quot;&gt;has a lot they still want to implement&lt;/a&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;into&lt;code style=&quot;color: #003366;&quot;&gt;FULLTEXT&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;searching. Here is a brief overview of those enhancements:&lt;br /&gt;
&lt;ul style=&quot;padding-left: 25px;&quot;&gt;&lt;li&gt;Proximity operators&lt;/li&gt;
&lt;li&gt;Making the stopword lists depend on the language of the data&lt;/li&gt;
&lt;li&gt;Stemming&lt;/li&gt;
&lt;/ul&gt;The proximity operators will really make&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;FULLTEXT&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;searching impressive. This will allow you to do searches on words based on how close together they are. For example, if you currently searched for &#39;mysql search&#39; you would get results even where&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;mysql&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;and&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;search&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;appear at opposite ends of the document. With proximity operators, the scoring algorithm gauges how close together the words are. Documents where&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;mysql&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;and&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;search&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;appeared directly next to one another would score higher than documents where they were not close together.&lt;br /&gt;
&lt;a href=&quot;http://www.tartarus.org/%7Emartin/PorterStemmer/&quot;&gt;Stemming&lt;/a&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;is a great way to make search engines smarter. This would allow MySQL to search for words that share the same lexical root. For example, queries for&lt;code style=&quot;color: #003366;&quot;&gt;running&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;would return documents with&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;ran&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;and&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;run&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;as well as&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;running&lt;/code&gt;.&lt;br /&gt;
&lt;h3 style=&quot;font-size: 14px; font-weight: bold;&quot;&gt;Conclusion&lt;/h3&gt;As you can see, the possibilities of&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;code style=&quot;color: #003366;&quot;&gt;FULLTEXT&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;are almost endless. For those of us looking for an easy and powerful solution to our searching woes, MySQL has come up with an answer.&lt;br /&gt;
&lt;i&gt;&lt;a href=&quot;http://onlamp.com/pub/au/1234&quot;&gt;Joe Stump&lt;/a&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;is the Lead Architect for Digg where he spends his time partitioning data, creating internal services, and ensuring the code frameworks are in working order.&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://abdulzahra-alameri-php.blogspot.com/feeds/820248793145072208/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://abdulzahra-alameri-php.blogspot.com/2011/04/mysql-fulltext-searching.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3932080116325211990/posts/default/820248793145072208'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3932080116325211990/posts/default/820248793145072208'/><link rel='alternate' type='text/html' href='http://abdulzahra-alameri-php.blogspot.com/2011/04/mysql-fulltext-searching.html' title='MySQL FULLTEXT Searching'/><author><name>Global Shia TV Project</name><uri>http://www.blogger.com/profile/11068816266747627374</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3932080116325211990.post-3774659855826157828</id><published>2011-03-30T15:54:00.000-07:00</published><updated>2011-03-30T15:54:33.872-07:00</updated><title type='text'>MySQL Commands List</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;h1 style=&quot;color: #666666; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold;&quot;&gt;MySQL Commands List&lt;/h1&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;Here you will find a collection of basic MySQL statements that should prove useful for basic CRUDS operations (create, replace, update, delete, select).&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;There may be some issues with the kind of quotes you use around your data. If you are having difficulties, try using singe quotes (&amp;nbsp; &#39;&amp;nbsp; ) or tricky quotes (&amp;nbsp; `&amp;nbsp; -- on keyboard key next to number 1) around your data. One or the other is bound to work.&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;The following statements are covered in this page:&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;a href=&quot;http://www.gieson.com/school/mysql/index.html#create_database&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;&lt;iframe align=&quot;left&quot; frameborder=&quot;0&quot; marginheight=&quot;0&quot; marginwidth=&quot;0&quot; scrolling=&quot;no&quot; src=&quot;http://rcm.amazon.com/e/cm?t=imamhussainyoutf-20&amp;amp;o=1&amp;amp;p=8&amp;amp;l=bpl&amp;amp;asins=0071605495&amp;amp;fc1=000000&amp;amp;IS2=1&amp;amp;lt1=_blank&amp;amp;m=amazon&amp;amp;lc1=0000FF&amp;amp;bc1=000000&amp;amp;bg1=FFFFFF&amp;amp;f=ifr&quot; style=&quot;height: 245px; padding-right: 10px; padding-top: 5px; width: 131px;&quot;&gt;&lt;/iframe&gt;CREATE DATABASE&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.gieson.com/school/mysql/index.html#create_table&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;CREATE TABLE&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.gieson.com/school/mysql/index.html#insert&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;INSERT&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.gieson.com/school/mysql/index.html#replace&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;REPLACE&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.gieson.com/school/mysql/index.html#update&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;UPDATE&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.gieson.com/school/mysql/index.html#select&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;SELECT&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.gieson.com/school/mysql/index.html#delete&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;DELETE&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;a href=&quot;http://www.gieson.com/school/mysql/index.html#values&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;VALUES&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.gieson.com/school/mysql/index.html#set&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;SET&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.gieson.com/school/mysql/index.html#where&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;WHERE&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.gieson.com/school/mysql/index.html#in&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;IN&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.gieson.com/school/mysql/index.html#and&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;AND&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.gieson.com/school/mysql/index.html#or&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;OR&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.gieson.com/school/mysql/index.html#rlike&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;RLIKE&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.gieson.com/school/mysql/index.html#distinct&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;DISTINCT&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.gieson.com/school/mysql/index.html#max&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;MAX&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;a href=&quot;&quot; id=&quot;create_database&quot; name=&quot;create_database&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;CREATE DATABASE&lt;/b&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;CREATE DATABASE&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;database_name ;&lt;/div&gt;&lt;blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;Will create a MySQL database.&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;You may have to ensure that the user you used to log in has enough privileges to create databases.&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;Some web hosting companies do not allow their customers to create databases -- as they have already created a couple databases for you. In this case you should already have enough privy&#39;s to create tables on the already created databases. Check with your hosting provider to see what the proper database names are and what the usernames and passwords are for the database(s).&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeExample&quot; style=&quot;background-color: #efefef; border: 1px solid rgb(204, 204, 204); color: #3300ff; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 12px; padding: 5px;&quot;&gt;CREATE DATABASE myMediaLibrary;&lt;/div&gt;&lt;/blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;a href=&quot;&quot; id=&quot;create_table&quot; name=&quot;create_table&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;CREATE TABLE&lt;/b&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;Create a table on the database you are currently logged into.&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeExample&quot; style=&quot;background-color: #efefef; border: 1px solid rgb(204, 204, 204); color: #3300ff; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 12px; padding: 5px;&quot;&gt;CREATE TABLE IF NOT EXISTS `music` (&lt;br /&gt;
`id` int(8) unsigned NOT NULL,&lt;br /&gt;
`artist` text NOT NULL,&lt;br /&gt;
`album` text NOT NULL,&lt;br /&gt;
`title` text NOT NULL,&lt;br /&gt;
`track` text NOT NULL,&lt;br /&gt;
`year` varchar(8) NOT NULL,&lt;br /&gt;
PRIMARY KEY (`id`),&lt;br /&gt;
FULLTEXT KEY `artist` (`artist`),&lt;br /&gt;
FULLTEXT KEY `album` (`album`),&lt;br /&gt;
FULLTEXT KEY `title` (`title`),&lt;br /&gt;
FULLTEXT KEY `track` (`track`),&lt;br /&gt;
FULLTEXT KEY `year` (`year`)&lt;br /&gt;
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;The table set up will be similar to:&lt;/div&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; class=&quot;singleOutline&quot; style=&quot;background-color: white; border-collapse: collapse; border: 0px outset rgb(204, 204, 204); font-family: Arial,Helvetica,sans-serif; font-size: 12px; margin: 0px; padding: 0px; width: 495px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;102&quot;&gt;&lt;b&gt;id&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;102&quot;&gt;&lt;b&gt;artist&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;149&quot;&gt;&lt;b&gt;album&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;249&quot;&gt;&lt;b&gt;title&lt;/b&gt;&lt;/td&gt;&lt;td align=&quot;right&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;22&quot;&gt;&lt;b&gt;track&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;2&quot;&gt;&lt;b&gt;year&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;a href=&quot;&quot; id=&quot;auto_increment&quot; name=&quot;auto_increment&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;&lt;/a&gt;NOTE: You may want to use AUTO INCREMENT to have MySQL automatically maintain the id field when you add a new item to the table. This is up to you on how you would like to maintain the id., which in this case is the &quot;PRIMARY KEY&quot; which needs to be unique and is what MySQL needs to keep things orderly:&lt;/div&gt;&lt;div class=&quot;codeExample&quot; style=&quot;background-color: #efefef; border: 1px solid rgb(204, 204, 204); color: #3300ff; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 12px; padding: 5px;&quot;&gt;CREATE TABLE IF NOT EXISTS `music` (&lt;br /&gt;
`id` int(8) unsigned NOT NULL&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;AUTO_INCREMENT&lt;/span&gt;,&lt;br /&gt;
`artist` text NOT NULL,&lt;br /&gt;
`album` text NOT NULL,&lt;br /&gt;
`title` text NOT NULL,&lt;br /&gt;
`track` text NOT NULL,&lt;br /&gt;
`year` varchar(8) NOT NULL,&lt;br /&gt;
PRIMARY KEY (`id`),&lt;br /&gt;
FULLTEXT KEY `artist` (`artist`),&lt;br /&gt;
FULLTEXT KEY `album` (`album`),&lt;br /&gt;
FULLTEXT KEY `title` (`title`),&lt;br /&gt;
FULLTEXT KEY `track` (`track`),&lt;br /&gt;
FULLTEXT KEY `year` (`year`)&lt;br /&gt;
) ENGINE=MyISAM DEFAULT CHARSET=utf8&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;AUTO_INCREMENT=1&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;Refer to the MySQL documentation for more info on defining column data types.&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;a href=&quot;&quot; id=&quot;insert&quot; name=&quot;insert&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;&lt;/a&gt;&lt;a href=&quot;&quot; id=&quot;values&quot; name=&quot;values&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;INSERT STATEMENTS&lt;/b&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;INSERT INTO&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;table_name ( `&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;col_A&lt;/b&gt;&lt;/span&gt;`, `&lt;b&gt;&lt;span style=&quot;color: #009900;&quot;&gt;col_B&lt;/span&gt;&lt;/b&gt;`, `&lt;b&gt;&lt;span style=&quot;color: #ff0099;&quot;&gt;col_C&lt;/span&gt;&lt;/b&gt;`)&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;VALUES&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;( `&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;col_A_data&lt;/b&gt;&lt;/span&gt;`, `&lt;span style=&quot;color: #009900;&quot;&gt;&lt;b&gt;col_B_data&lt;/b&gt;&lt;/span&gt;`, `&lt;b&gt;&lt;span style=&quot;color: #ff0099;&quot;&gt;col_C_data&lt;/span&gt;&lt;/b&gt;`) ;&lt;/div&gt;&lt;blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;Inserts a row into the table using the data defined in the VALUES section.&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;As you can see, the column names are established within the first set of parenthesis, the order of the data in the second set of parenthesis must match the order of the column names defined int he first set of parentheses.&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeExample&quot; style=&quot;background-color: #efefef; border: 1px solid rgb(204, 204, 204); color: #3300ff; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 12px; padding: 5px;&quot;&gt;INSERT INTO music ( &#39;id&#39;, `artist`, `album`) VALUES ( &#39;1&#39;, `the beatles`, `Abbey Road`);&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;Puts a row into the database tables as:&lt;/div&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; class=&quot;singleOutline&quot; style=&quot;background-color: white; border-collapse: collapse; border: 0px outset rgb(204, 204, 204); font-family: Arial,Helvetica,sans-serif; font-size: 12px; margin: 0px; padding: 0px; width: 495px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;102&quot;&gt;&lt;b&gt;id&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;102&quot;&gt;&lt;b&gt;artist&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;149&quot;&gt;&lt;b&gt;album&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;249&quot;&gt;&lt;b&gt;title&lt;/b&gt;&lt;/td&gt;&lt;td align=&quot;right&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;22&quot;&gt;&lt;b&gt;track&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;2&quot;&gt;&lt;b&gt;year&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;1&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;the beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;I&#39;ve color coded each &quot;pair&quot; so you can see that the data &quot;&lt;b&gt;&lt;span style=&quot;color: #009900;&quot;&gt;col_B_data&#39;&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;that is going to go into column name &quot;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;b&gt;col_B&lt;/b&gt;&lt;/span&gt;&quot; must be second. if there is no data available for col_B, use empty single quotes as:&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;INSERT INTO&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;table_name ( `&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;col_A&lt;/b&gt;&lt;/span&gt;`, `&lt;b&gt;&lt;span style=&quot;color: #009900;&quot;&gt;col_B&lt;/span&gt;&lt;/b&gt;`, `&lt;b&gt;&lt;span style=&quot;color: #ff0099;&quot;&gt;col_C&lt;/span&gt;&lt;/b&gt;`)&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;VALUES&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;( `&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;col A data&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;`, ``, `&lt;b&gt;&lt;span style=&quot;color: #ff0099;&quot;&gt;col C data&lt;/span&gt;&lt;/b&gt;`) ;&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeExample&quot; style=&quot;background-color: #efefef; border: 1px solid rgb(204, 204, 204); color: #3300ff; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 12px; padding: 5px;&quot;&gt;INSERT INTO music ( &#39;id&#39;, `artist`, `album`) VALUES ( &#39;1&#39;, ``, `Abbey Road`);&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;Puts a row into the database tables as:&lt;/div&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; class=&quot;singleOutline&quot; style=&quot;background-color: white; border-collapse: collapse; border: 0px outset rgb(204, 204, 204); font-family: Arial,Helvetica,sans-serif; font-size: 12px; margin: 0px; padding: 0px; width: 495px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;102&quot;&gt;&lt;b&gt;id&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;102&quot;&gt;&lt;b&gt;artist&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;149&quot;&gt;&lt;b&gt;album&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;249&quot;&gt;&lt;b&gt;title&lt;/b&gt;&lt;/td&gt;&lt;td align=&quot;right&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;22&quot;&gt;&lt;b&gt;track&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;2&quot;&gt;&lt;b&gt;year&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;1&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;a href=&quot;&quot; id=&quot;replace&quot; name=&quot;replace&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;REPLACE STATEMENTS&lt;/b&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;REPLACE INTO&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;table_name ( `col_A`, `col_B`)&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;VALUES&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;( `col A data`, `col B data`) ;&lt;/div&gt;&lt;blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;Replaces items in a row. &amp;nbsp; This action is dependant on the &quot;id&quot; because all tables need to have at least one &quot;unique&quot; column. Meaning that one of the columns must be used to provide row data that is unique to each row. In this example, &quot;id&quot; is the unique row.&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeExample&quot; style=&quot;background-color: #efefef; border: 1px solid rgb(204, 204, 204); color: #3300ff; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 12px; padding: 5px;&quot;&gt;REPLACE INTO music ( &#39;id&#39;, `artist`, `album`) VALUES ( &#39;1&#39;, `the beatles`, `abbey road`);&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;Puts a row into the database tables as:&lt;/div&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; class=&quot;singleOutline&quot; style=&quot;background-color: white; border-collapse: collapse; border: 0px outset rgb(204, 204, 204); font-family: Arial,Helvetica,sans-serif; font-size: 12px; margin: 0px; padding: 0px; width: 495px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;102&quot;&gt;&lt;b&gt;id&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;102&quot;&gt;&lt;b&gt;artist&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;149&quot;&gt;&lt;b&gt;album&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;249&quot;&gt;&lt;b&gt;title&lt;/b&gt;&lt;/td&gt;&lt;td align=&quot;right&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;22&quot;&gt;&lt;b&gt;track&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;2&quot;&gt;&lt;b&gt;year&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;1&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;the beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;As you can see, we&#39;ve just replaced the empty &quot;artist&quot; with the new data of &quot;the beatles&quot;&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;REPLACE behaves much like INSERT except that if the &quot;unique column&quot; is supplied, the existing row will be updated, if the &quot;unique column&quot; is not provided, a new row will be added.&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeExample&quot; style=&quot;background-color: #efefef; border: 1px solid rgb(204, 204, 204); color: #3300ff; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 12px; padding: 5px;&quot;&gt;REPLACE INTO music ( `artist`, `album`) VALUES ( `the beatles`, `abbey road`);&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;Puts a&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;new&lt;/b&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;row into the database tables as:&lt;/div&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; class=&quot;singleOutline&quot; style=&quot;background-color: white; border-collapse: collapse; border: 0px outset rgb(204, 204, 204); font-family: Arial,Helvetica,sans-serif; font-size: 12px; margin: 0px; padding: 0px; width: 495px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;102&quot;&gt;&lt;b&gt;id&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;102&quot;&gt;&lt;b&gt;artist&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;149&quot;&gt;&lt;b&gt;album&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;249&quot;&gt;&lt;b&gt;title&lt;/b&gt;&lt;/td&gt;&lt;td align=&quot;right&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;22&quot;&gt;&lt;b&gt;track&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;2&quot;&gt;&lt;b&gt;year&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;1&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;the beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;the beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;NOTE: You may get errors when trying this kind of REPLACE, because usually the &quot;unique column&quot; can not be null (or empty). Some people like to set up the database where the &quot;unique column&quot; is automatically incremented by MySQL. This is kind of confusing and can lead to a headache. So just remember to include the &quot;unique column&quot; when using the REPLACE statement, or you&#39;ll get duplicate rows... OR use the UPDATE statement.&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;a href=&quot;&quot; id=&quot;update&quot; name=&quot;update&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;&lt;/a&gt;&lt;a href=&quot;&quot; id=&quot;set&quot; name=&quot;set&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;&lt;/a&gt;&lt;a href=&quot;&quot; id=&quot;where&quot; name=&quot;where&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;UPDATE STATEMENTS&lt;/b&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;UPDATE&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;table_name&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;SET&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;col_B=&#39;new_data&#39;&amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;WHERE&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;col_A=&#39;reference_data&#39; ;&lt;/div&gt;&lt;blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;Will update a row&#39;s columns with the new values specified in the SET section and the row to update is specified by the WHERE section&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeExample&quot; style=&quot;background-color: #efefef; border: 1px solid rgb(204, 204, 204); color: #3300ff; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 12px; padding: 5px;&quot;&gt;UPDATE music SET title=&#39;Come Together&#39;&amp;nbsp;WHERE id=1;&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;Notice that quotes are not around the id-1. This is because you shouldn&#39;t have to use quotes when you are entering an integer.&lt;/div&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; class=&quot;singleOutline&quot; style=&quot;background-color: white; border-collapse: collapse; border: 0px outset rgb(204, 204, 204); font-family: Arial,Helvetica,sans-serif; font-size: 12px; margin: 0px; padding: 0px; width: 495px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;102&quot;&gt;&lt;b&gt;id&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;102&quot;&gt;&lt;b&gt;artist&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;149&quot;&gt;&lt;b&gt;album&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;249&quot;&gt;&lt;b&gt;title&lt;/b&gt;&lt;/td&gt;&lt;td align=&quot;right&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;22&quot;&gt;&lt;b&gt;track&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;2&quot;&gt;&lt;b&gt;year&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;1&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;the beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Come Together&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;To update two or more columns, separate value pairs in the SET section with a comma&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeExample&quot; style=&quot;background-color: #efefef; border: 1px solid rgb(204, 204, 204); color: #3300ff; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 12px; padding: 5px;&quot;&gt;UPDATE music SET track=&#39;1&#39;, year=&#39;1969&#39; &amp;nbsp;WHERE id=1;&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;Notice that quotes are not around the id-1. This is because you shouldn&#39;t have to use quotes when you are entering an integer.&lt;/div&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; class=&quot;singleOutline&quot; style=&quot;background-color: white; border-collapse: collapse; border: 0px outset rgb(204, 204, 204); font-family: Arial,Helvetica,sans-serif; font-size: 12px; margin: 0px; padding: 0px; width: 495px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;102&quot;&gt;&lt;b&gt;id&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;102&quot;&gt;&lt;b&gt;artist&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;149&quot;&gt;&lt;b&gt;album&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;249&quot;&gt;&lt;b&gt;title&lt;/b&gt;&lt;/td&gt;&lt;td align=&quot;right&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;22&quot;&gt;&lt;b&gt;track&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;2&quot;&gt;&lt;b&gt;year&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;1&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;the beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Come Together&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;1&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;It may seem frustrating to see that quotes were used around the &quot;integers&#39; in the SET section, but not in the WHERE section. Sometimes you may need to use them, but sometimes you do not. A llot of it depends on how the database was originally set up. If we initially set up the database where &quot;track&quot; and &quot;year&quot; did not use TEXT, but rather INT(11) we could probably get away with not using quotes around the data in the SET section. This issue also has to do with how MySQL is set up on your server.&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;Another thing to consider is that because we&#39;re using single quotes around the data that we are entering... what if your data contains a single quote? Such as:&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;span class=&quot;codeExample&quot; style=&quot;background-color: #efefef; border: 1px solid rgb(204, 204, 204); color: #3300ff; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 12px; padding: 5px;&quot;&gt;UPDATE music SET title=&#39;Mike&#39;s Song&#39;&amp;nbsp;WHERE id=1;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;As you can see, now there are three single quotes, and chances are MySQL will return an error. There are two things you can try.&lt;/div&gt;&lt;blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;1. Escape the single quote in the data as:&lt;/div&gt;&lt;blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;span class=&quot;codeExample&quot; style=&quot;background-color: #efefef; border: 1px solid rgb(204, 204, 204); color: #3300ff; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 12px; padding: 5px;&quot;&gt;UPDATE music SET title=&#39;Mike\&#39;s Song&#39;&amp;nbsp;WHERE id=1;&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;1. Use tricky quotes:&lt;/div&gt;&lt;blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;span class=&quot;codeExample&quot; style=&quot;background-color: #efefef; border: 1px solid rgb(204, 204, 204); color: #3300ff; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 12px; padding: 5px;&quot;&gt;UPDATE music SET title=`Mike&#39;s Song`&amp;nbsp;WHERE id=1;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;Tricky quotes are just above the &quot;tab&quot; button on your keyboard.&lt;/div&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;a href=&quot;&quot; id=&quot;select&quot; name=&quot;select&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;SELECT STATEMENTS&lt;/b&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;SELECT&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;*&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;FROM&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;table_name&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;WHERE&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;1 ;&lt;/div&gt;&lt;blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;Returns all rows and all columns from table_name.. All rows is specified by the * (asterisk) symbol between SELECT and FROM.&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeExample&quot; style=&quot;background-color: #efefef; border: 1px solid rgb(204, 204, 204); color: #3300ff; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 12px; padding: 5px;&quot;&gt;SELECT * FROM music WHERE 1;&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;Returns:&lt;/b&gt;&lt;/div&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; class=&quot;singleOutline&quot; style=&quot;background-color: white; border-collapse: collapse; border: 0px outset rgb(204, 204, 204); font-family: Arial,Helvetica,sans-serif; font-size: 12px; margin: 0px; padding: 0px; width: 495px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;102&quot;&gt;&lt;b&gt;id&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;102&quot;&gt;&lt;b&gt;artist&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;149&quot;&gt;&lt;b&gt;album&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;249&quot;&gt;&lt;b&gt;title&lt;/b&gt;&lt;/td&gt;&lt;td align=&quot;right&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;22&quot;&gt;&lt;b&gt;track&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;2&quot;&gt;&lt;b&gt;year&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;1&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;the beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Come Together&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;1&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;2&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;the beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Something&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;2&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;3&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;the beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Maxwell&#39;s Silver Hammer&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;3&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;4&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;the beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Oh! Darling&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;4&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;5&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;the beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Octopus&#39;s Garden&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;5&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;6&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;the beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;I Want You (She&#39;s So Heavy)&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;6&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;7&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;the beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Here Comes the Sun&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;7&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;8&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;the beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Because&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;8&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;9&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;the beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;You Never Give Me Your Money&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;9&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;10&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;the beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Sun King&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;10&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;11&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;the beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Mean Mr. Mustard&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;11&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;12&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;the beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Polythene Pam&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;12&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;13&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;the beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;She Came in Through the Bathroom Window&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;13&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;14&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;the beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Golden Slumbers&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;14&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;15&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;the beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Carry That Weight&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;15&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;16&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;the beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;The End&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;16&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;17&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;the beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Her Majesty&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;17&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;18&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Rubber Soul&lt;/td&gt;&lt;td style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Drive My Car&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;1&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;19&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Rubber Soul&lt;/td&gt;&lt;td style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Norwegian Wood (This Bird Has Flown)&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;2&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;20&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Rubber Soul&lt;/td&gt;&lt;td style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;You Won&#39;t See Me&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;3&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;21&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Rubber Soul&lt;/td&gt;&lt;td style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Nowhere Man&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;4&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;22&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Rubber Soul&lt;/td&gt;&lt;td style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Think for Yourself&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;5&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;23&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Rubber Soul&lt;/td&gt;&lt;td style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;The Word&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;6&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;24&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Rubber Soul&lt;/td&gt;&lt;td style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Michelle&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;7&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;25&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Rubber Soul&lt;/td&gt;&lt;td style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;What Goes On&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;8&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;26&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Rubber Soul&lt;/td&gt;&lt;td style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Girl&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;9&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;27&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Rubber Soul&lt;/td&gt;&lt;td style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;I&#39;m Looking Through You&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;10&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;28&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Rubber Soul&lt;/td&gt;&lt;td style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;In My Life&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;11&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;29&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Rubber Soul&lt;/td&gt;&lt;td style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Wait&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;12&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;30&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Rubber Soul&lt;/td&gt;&lt;td style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;If I Needed Someone&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;13&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;31&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Rubber Soul&lt;/td&gt;&lt;td style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Run for Your Life&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;14&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;SELECT&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;*&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;FROM&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;table_name&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;WHERE&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;column_name&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;IN&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;(&#39;data_1&#39;,&#39;data_2&#39;) ;&lt;/div&gt;&lt;blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;Returns all rows* and all columns that have matching data specified in the IN section. The data defined in the IN section must match exactly.&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;NOTE:&lt;/b&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;All rows is specified by the * symbol between SELECT and FROM sections.&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeExample&quot; style=&quot;background-color: #efefef; border: 1px solid rgb(204, 204, 204); color: #3300ff; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 12px; padding: 5px;&quot;&gt;SELECT * FROM music WHERE track IN (&#39;1&#39;,&#39;2&#39;);&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;Returns&lt;/b&gt;:&lt;/div&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; class=&quot;singleOutline&quot; style=&quot;background-color: white; border-collapse: collapse; border: 0px outset rgb(204, 204, 204); font-family: Arial,Helvetica,sans-serif; font-size: 12px; margin: 0px; padding: 0px; width: 495px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;102&quot;&gt;&lt;b&gt;id&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;102&quot;&gt;&lt;b&gt;artist&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;149&quot;&gt;&lt;b&gt;album&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;249&quot;&gt;&lt;b&gt;title&lt;/b&gt;&lt;/td&gt;&lt;td align=&quot;right&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;22&quot;&gt;&lt;b&gt;track&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;2&quot;&gt;&lt;b&gt;year&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;1&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;the beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Come Together&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;1&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;2&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;the beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Something&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;2&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;18&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Rubber Soul&lt;/td&gt;&lt;td style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Drive My Car&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;1&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;19&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Rubber Soul&lt;/td&gt;&lt;td style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Norwegian Wood (This Bird Has Flown)&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;2&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;SELECT&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;col_A_name, col_B_name&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;FROM&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;table_name&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;WHERE&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;col_B_name=&#39;search_term&#39; ;&lt;/div&gt;&lt;blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;Returns only two columns from the matching row. The data defined int eh WHERE section must match exactly.&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeExample&quot; style=&quot;background-color: #efefef; border: 1px solid rgb(204, 204, 204); color: #3300ff; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 12px; padding: 5px;&quot;&gt;SELECT artist, album FROM music WHERE title=&#39;You Never Give Me Your Money&#39;;&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;Returns:&lt;/b&gt;&lt;/div&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; class=&quot;singleOutline&quot; style=&quot;background-color: white; border-collapse: collapse; border: 0px outset rgb(204, 204, 204); font-family: Arial,Helvetica,sans-serif; font-size: 12px; margin: 0px; padding: 0px; width: 271px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;102&quot;&gt;&lt;b&gt;artist&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;149&quot;&gt;&lt;b&gt;album&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;the beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;a href=&quot;&quot; id=&quot;in&quot; name=&quot;in&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;SELECT&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;col_A_name, col_B_name&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;FROM&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;table_name&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;WHERE&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;col_B_name&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;IN&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;(&#39;search_term_1&#39;,&#39;search_term_2&#39;) ;&lt;/div&gt;&lt;blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;Returns only two columns that match the data defined in the IN section.&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeExample&quot; style=&quot;background-color: #efefef; border: 1px solid rgb(204, 204, 204); color: #3300ff; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 12px; padding: 5px;&quot;&gt;SELECT title, album FROM music WHERE title=&#39;You Won\&#39;t See Me&#39;, &#39;I\&#39;m Looking Through You&#39;;&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;NOTE: Notice that the single quotes are &quot;escaped&quot; by using a back slash within the data. You may want to try using tricky quotes instead as:&lt;/div&gt;&lt;div class=&quot;codeExample&quot; style=&quot;background-color: #efefef; border: 1px solid rgb(204, 204, 204); color: #3300ff; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 12px; padding: 5px;&quot;&gt;SELECT album, date FROM music WHERE title=`You Won&#39;t See Me`, `I&#39;m Looking Through You`;&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;Returns:&lt;/b&gt;&lt;/div&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; class=&quot;singleOutline&quot; style=&quot;background-color: white; border-collapse: collapse; border: 0px outset rgb(204, 204, 204); font-family: Arial,Helvetica,sans-serif; font-size: 12px; margin: 0px; padding: 0px; width: 418px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;149&quot;&gt;&lt;b&gt;album&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;249&quot;&gt;&lt;b&gt;date&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Rubber Soul&lt;/td&gt;&lt;td style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Rubber Soul&lt;/td&gt;&lt;td style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;a href=&quot;&quot; id=&quot;rlike&quot; name=&quot;rlike&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;&lt;/a&gt;&lt;a href=&quot;&quot; id=&quot;or&quot; name=&quot;or&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;SELECT&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;*&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;FROM&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;table_name&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;WHERE&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;col_A_name&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;RLIKE&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;(&#39;search_termA&#39;)&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;OR&lt;/b&gt;&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;col_B_name&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;RLIKE&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;(&#39;search_termB&#39;) ;&lt;/div&gt;&lt;blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;This example will search through your table for matching words.&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;Will return all rows that contain either search_termA&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;OR&lt;/b&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;search_term_B -- the search term can be a single word or a phrase.&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;NOTE: This options is based on having MySQL set up to take advantage of FULLTEXT, which was established when we set up the table. Also note that some MySQL configurations will not return matches on words that are shorter than 4 characters. So for this example, MySQL may not return anything. So you may want to experiment with this kind of search with a larger word such as &quot;Yourself.&quot;&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;NOTE 2: This is actually the old way to do things, but more reliable than the new method. The new method uses the MATCH statement, but requires some additional configuration on your MySQL installation / server. The method offered here is probably a little more reliable as of this writing.&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;NOTE TO SELF: If the year is 2013, you may have better luck using the MATCH statement. I&#39;m sure I&#39;ll be dead by then, so your on your own. Check with the MySQL documentation.&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeExample&quot; style=&quot;background-color: #efefef; border: 1px solid rgb(204, 204, 204); color: #3300ff; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 12px; padding: 5px;&quot;&gt;SELECT * FROM music WHERE title RLIKE (&#39;you&#39;)&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;OR&lt;/b&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;title RLIKE (&#39;mustard&#39;) ;&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;Returns:&lt;/b&gt;&lt;/div&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; class=&quot;singleOutline&quot; style=&quot;background-color: white; border-collapse: collapse; border: 0px outset rgb(204, 204, 204); font-family: Arial,Helvetica,sans-serif; font-size: 12px; margin: 0px; padding: 0px; width: 495px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;102&quot;&gt;&lt;b&gt;id&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;102&quot;&gt;&lt;b&gt;artist&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;149&quot;&gt;&lt;b&gt;album&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;249&quot;&gt;&lt;b&gt;title&lt;/b&gt;&lt;/td&gt;&lt;td align=&quot;right&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;22&quot;&gt;&lt;b&gt;track&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;2&quot;&gt;&lt;b&gt;year&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;6&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;the beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;I Want&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;You&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;(She&#39;s So Heavy)&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;6&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;9&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;the beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;You&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;Never Give Me Your Money&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;9&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;20&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Rubber Soul&lt;/td&gt;&lt;td style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;You&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;Won&#39;t See Me&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;3&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;27&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Rubber Soul&lt;/td&gt;&lt;td style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;I&#39;m Looking Through&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;You&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;10&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;11&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;the beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Mean Mr.&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;Mustard&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;11&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;blockquote&gt;&lt;a href=&quot;&quot; id=&quot;and&quot; name=&quot;and&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;&lt;/a&gt;&lt;/blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;SELECT&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;*&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;FROM&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;table_name&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;WHERE&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;col_A_name&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;RLIKE&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;(&#39;search_termA&#39;)&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;AND&lt;/b&gt;&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;col_B_name&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;RLIKE&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;(&#39;search_termB&#39;) ;&lt;/div&gt;&lt;blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;This example will search through your table for matching words.&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;Will return all rows that contain either search_termA&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;OR&lt;/b&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;search_term_B -- the search terms can be a single word or a phrase.&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeExample&quot; style=&quot;background-color: #efefef; border: 1px solid rgb(204, 204, 204); color: #3300ff; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 12px; padding: 5px;&quot;&gt;SELECT * FROM music WHERE title RLIKE (&#39;you&#39;)&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;AND&lt;/b&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;title RLIKE (&#39;me&#39;) ;&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;Returns:&lt;/b&gt;&lt;/div&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; class=&quot;singleOutline&quot; style=&quot;background-color: white; border-collapse: collapse; border: 0px outset rgb(204, 204, 204); font-family: Arial,Helvetica,sans-serif; font-size: 12px; margin: 0px; padding: 0px; width: 495px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;102&quot;&gt;&lt;b&gt;id&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;102&quot;&gt;&lt;b&gt;artist&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;149&quot;&gt;&lt;b&gt;album&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;249&quot;&gt;&lt;b&gt;title&lt;/b&gt;&lt;/td&gt;&lt;td align=&quot;right&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;22&quot;&gt;&lt;b&gt;track&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;2&quot;&gt;&lt;b&gt;year&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;9&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;the beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;You&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;Never Give&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;Me&lt;/b&gt;&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;Your Money&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;9&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;20&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Rubber Soul&lt;/td&gt;&lt;td style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;You&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;Won&#39;t See&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;Me&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;3&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;NOTE:&lt;/b&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;In this example, we are only searching within the same column, you can search different columns if you want, and you can also add more OR or AND statements, or you can mix and match OR and AND statements to refine the search..&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeExample&quot; style=&quot;background-color: #efefef; border: 1px solid rgb(204, 204, 204); color: #3300ff; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 12px; padding: 5px;&quot;&gt;SELECT * FROM music WHERE title RLIKE (&#39;you&#39;)&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;OR&lt;/b&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;artist RLIKE (&#39;the&#39;) AND track RLIKE (&#39;1969&#39;);&lt;/div&gt;&lt;/blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;a href=&quot;&quot; id=&quot;order&quot; name=&quot;order&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;&lt;/a&gt;&lt;a href=&quot;&quot; id=&quot;rand&quot; name=&quot;rand&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;&lt;/a&gt;&lt;a href=&quot;&quot; id=&quot;limit&quot; name=&quot;limit&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;SELECT&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;*&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;FROM&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;table_name&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;WHERE&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;1&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;ORDER BY RAND() LIMIT&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;number_of_rows_to_return ;&lt;/div&gt;&lt;blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;Will select random rows and limit the number of rows returned to the number specified in the LIMIT section.&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeExample&quot; style=&quot;background-color: #efefef; border: 1px solid rgb(204, 204, 204); color: #3300ff; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 12px; padding: 5px;&quot;&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;SELECT&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;*&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;FROM&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;music&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;WHERE&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;1&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;ORDER BY RAND() LIMIT&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;3;&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;Returns something similar to :&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;(Can&#39;t be too sure here, since MySQL is picking rows randomly, but you can see that only three rows are returned :)&lt;/div&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; class=&quot;singleOutline&quot; style=&quot;background-color: white; border-collapse: collapse; border: 0px outset rgb(204, 204, 204); font-family: Arial,Helvetica,sans-serif; font-size: 12px; margin: 0px; padding: 0px; width: 495px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;102&quot;&gt;&lt;b&gt;id&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;102&quot;&gt;&lt;b&gt;artist&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;149&quot;&gt;&lt;b&gt;album&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;249&quot;&gt;&lt;b&gt;title&lt;/b&gt;&lt;/td&gt;&lt;td align=&quot;right&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;22&quot;&gt;&lt;b&gt;track&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;2&quot;&gt;&lt;b&gt;year&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;25&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Rubber Soul&lt;/td&gt;&lt;td style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;What Goes On&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;8&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;13&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;the beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;She Came in Through the Bathroom Window&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;13&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;5&lt;/td&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;the beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Octopus&#39;s Garden&lt;/td&gt;&lt;td align=&quot;left&quot; nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;5&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;1969&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;a href=&quot;&quot; id=&quot;distinct&quot; name=&quot;distinct&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;SELECT DISTINCT&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;col_A&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;FROM&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;table_name&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;WHERE&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;1;&lt;/div&gt;&lt;blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;Will only return rows that have unique data in the column specified.&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;Perhaps the best way to explain this is through example.&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;If we do something like this:&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codedBox&quot; style=&quot;background-color: #efefef; border: 1px solid rgb(204, 204, 204); color: #3300ff; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 12px; padding: 5px;&quot;&gt;SELECT DISTINCT year FROM music WHERE 1;&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;... we will only get one row and one column because all the rows in our table have &quot;1969&quot; set as the year. MySQL will pick the first unique row, all subsequent rows that have the same data in the specified column will not be returned, because the data in the other rows is not unique.&lt;/div&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; class=&quot;singleOutline&quot; style=&quot;background-color: white; border-collapse: collapse; border: 0px outset rgb(204, 204, 204); font-family: Arial,Helvetica,sans-serif; font-size: 12px; margin: 0px; padding: 0px; width: 12px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;2&quot;&gt;&lt;b&gt;year&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;1969&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;If we do something like:&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codedBox&quot; style=&quot;background-color: #efefef; border: 1px solid rgb(204, 204, 204); color: #3300ff; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 12px; padding: 5px;&quot;&gt;SELECT DISTINCT artist FROM music WHERE 1;&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;We&#39;ll only get two rows:&lt;/div&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; class=&quot;singleOutline&quot; style=&quot;background-color: white; border-collapse: collapse; border: 0px outset rgb(204, 204, 204); font-family: Arial,Helvetica,sans-serif; font-size: 12px; margin: 0px; padding: 0px; width: 112px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;102&quot;&gt;&lt;b&gt;artist&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;the beatles&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;beatles&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;... because the for the first album, we used &quot;the beatles&quot; whereas the second album, we just used &quot;beatles&quot; -- so only the first row that MySQL encounters with unique data in the &quot;artist&quot; column will be returned... because the rest of the rows are not unique.&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;SELECT&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;DISTINCT&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;col_A,col_B&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;FROM&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;table_name&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;WHERE&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;1&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;ORDER BY RAND() LIMIT&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;number_of_rows_to_return ;&lt;/div&gt;&lt;blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;You can add the DISTINCT statement to any statement. So that only unique items are returned. Or another way to think about it is that no duplicate rows are returned. For example, if you used the RLIKE statement to look for a couple key words, MySQL may return the dame row two times, you can use the DISTINCT statement to filter only unique rows.&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeExample&quot; style=&quot;background-color: #efefef; border: 1px solid rgb(204, 204, 204); color: #3300ff; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 12px; padding: 5px;&quot;&gt;SELECT DISTINCT artist,album FROM music WHERE 1 ORDER BY RAND() LIMIT 5;&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;This example is deviating slightly from out standard &quot;All beatles&quot; table, in this example, we&#39;ll have to imaging that our tables contains a whole bunch of artists and albums.&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;So, with your imagination flying, the example above would return 5&amp;nbsp; rows, where both the artist and album are unique.&lt;/div&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; class=&quot;singleOutline&quot; style=&quot;background-color: white; border-collapse: collapse; border: 0px outset rgb(204, 204, 204); font-family: Arial,Helvetica,sans-serif; font-size: 12px; margin: 0px; padding: 0px; width: 495px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;102&quot;&gt;&lt;b&gt;artist&lt;/b&gt;&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; width=&quot;149&quot;&gt;&lt;b&gt;album&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Rubber Soul&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;the beatles&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Abbey Road&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;Ray Lamontagne&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Trouble&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;The Tragically Hip&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Wheat kings&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;The Police&lt;/td&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot;&gt;Outlandos d&#39;Amour&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;NOTE: Yes, both &quot;the beatles&quot; and &quot;beatles&quot; albums would be returned because the entire data contained in the &quot;artist&quot; column is unique for both of these albums.&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;a href=&quot;&quot; id=&quot;max&quot; name=&quot;max&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;SELECT MAX&lt;/span&gt;(col_A)&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;FROM&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;table_name ;&lt;/div&gt;&lt;blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;Will return the highest value for that column. Usually you want to sue this on a column that references a number. For example, let&#39;s say you wanted to find the highest ID on your table so that you could determine the next ID to use fro a new item that you are inserting into your tables. You could use the MAX statement to find the largest ID number, then when you INSERT your new item, you can simply bump up the number by one.&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeExample&quot; style=&quot;background-color: #efefef; border: 1px solid rgb(204, 204, 204); color: #3300ff; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 12px; padding: 5px;&quot;&gt;SELECT MAX(id) FROM music;&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;Returns:&lt;/b&gt;&lt;/div&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; class=&quot;singleOutline&quot; style=&quot;background-color: white; border-collapse: collapse; border: 0px outset rgb(204, 204, 204); font-family: Arial,Helvetica,sans-serif; font-size: 12px; margin: 0px; padding: 0px; width: 56px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;102&quot;&gt;&lt;b&gt;id&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;31&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;... because the highest ID in our table is 31. e.g. there are 31 items in our table as defined by the ID column.&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;If we ran something like:&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;SELECT MAX&lt;/span&gt;(track)&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;FROM&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;music ;&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;... we&#39;d get:&lt;/div&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; class=&quot;singleOutline&quot; style=&quot;background-color: white; border-collapse: collapse; border: 0px outset rgb(204, 204, 204); font-family: Arial,Helvetica,sans-serif; font-size: 12px; margin: 0px; padding: 0px; width: 56px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot; width=&quot;102&quot;&gt;&lt;b&gt;track&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td nowrap=&quot;NOWRAP&quot; style=&quot;background-color: #faf9e6; border: 1px inset rgb(204, 204, 204); padding: 3px;&quot; valign=&quot;top&quot;&gt;17&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;... because 17 is the highest number in the &quot;track&quot; column&lt;/div&gt;&lt;/blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;a href=&quot;&quot; id=&quot;delete&quot; name=&quot;delete&quot; style=&quot;color: #003399; text-decoration: none;&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;DELETE STATEMENTS&lt;/b&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;DELETE FROM&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;table_name&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;WHERE&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;column_name=&#39;search_data&#39;;&lt;/div&gt;&lt;blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;Will remove rows that match the search data defined in the WHERE section&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeExample&quot; style=&quot;background-color: #efefef; border: 1px solid rgb(204, 204, 204); color: #3300ff; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 12px; padding: 5px;&quot;&gt;DELETE FROM music WHERE artist=&#39;the beatles&#39;;&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;Will remove all rows that have &quot;the beatles&quot; defined in the &quot;artist&quot; column.&lt;/div&gt;&lt;/blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;DELETE&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;FROM&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;table_name&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;WHERE&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;column_name&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mysqlCommand&quot; style=&quot;color: #cc0000;&quot;&gt;IN&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;(&#39;search_data_A&#39;, &#39;search_data_B&#39;);&lt;/div&gt;&lt;blockquote&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;Will remove all rows that match the search data defined in the IN section.&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeExample&quot; style=&quot;background-color: #efefef; border: 1px solid rgb(204, 204, 204); color: #3300ff; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 12px; padding: 5px;&quot;&gt;DELETE FROM music WHERE artist IN (&#39;the beatles&#39;, &#39;beatles&#39;);&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: Arial,Helvetica,sans-serif; font-size: 12px;&quot;&gt;... will remove all the items from our example table&lt;/div&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/span&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://abdulzahra-alameri-php.blogspot.com/feeds/3774659855826157828/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://abdulzahra-alameri-php.blogspot.com/2011/03/mysql-commands-list.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3932080116325211990/posts/default/3774659855826157828'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3932080116325211990/posts/default/3774659855826157828'/><link rel='alternate' type='text/html' href='http://abdulzahra-alameri-php.blogspot.com/2011/03/mysql-commands-list.html' title='MySQL Commands List'/><author><name>Abdul Zahra Al Ameri</name><uri>http://www.blogger.com/profile/16930336258404396441</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXoqssOhhRJKC36bZ0CJtGsg5nuarPlr4IerH_0kFBkpk_YNPxkfIWFoyL0M351NtBRxXjSYguz0iD9Tw-Y_o5aTgyHDQ9hSsr8A78WZ2l8dGvLaFgi4l9UmPR5Vsmk4w/s220/drinktea-medium.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3932080116325211990.post-3128206708927816241</id><published>2011-03-28T17:19:00.000-07:00</published><updated>2011-03-28T17:19:57.253-07:00</updated><title type='text'>How to copy export mySQL user priviledges</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #222222; font-family: Arial,Helvetica,sans-serif; font-size: 12px; line-height: 18px;&quot;&gt;&lt;h1 style=&quot;border-width: 0px; color: #111111; font-family: inherit; font-size: 1.3em; font-style: inherit; font-weight: bold; line-height: 1; margin: 0px 0px 0.5em; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&lt;iframe align=&quot;left&quot; frameborder=&quot;0&quot; marginheight=&quot;0&quot; marginwidth=&quot;0&quot; scrolling=&quot;no&quot; src=&quot;http://rcm.amazon.com/e/cm?t=imamhussainyoutf-20&amp;amp;o=1&amp;amp;p=8&amp;amp;l=bpl&amp;amp;asins=0071605495&amp;amp;fc1=000000&amp;amp;IS2=1&amp;amp;lt1=_blank&amp;amp;m=amazon&amp;amp;lc1=0000FF&amp;amp;bc1=000000&amp;amp;bg1=FFFFFF&amp;amp;f=ifr&quot; style=&quot;height: 245px; padding-right: 10px; padding-top: 5px; width: 131px;&quot;&gt;&lt;/iframe&gt;&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://www.adamsinfo.com/copy-export-mysql-user-priviledges/&quot; id=&quot;post-812&quot; rel=&quot;bookmark&quot; style=&quot;border-width: 0px; color: #ff6600; font-family: inherit; font-size: 16px; font-style: inherit; font-weight: inherit; margin: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot; title=&quot;Permanent Link to Copy/Export MySQL User Priviledges&quot;&gt;Copy/Export MySQL User Priviledges&lt;/a&gt;&lt;/h1&gt;&lt;div style=&quot;border-width: 0px; font-family: inherit; font-size: 12px; font-style: inherit; font-weight: inherit; margin: 0px 0px 1.5em; padding: 0px; vertical-align: baseline;&quot;&gt;I’m often asked how to copy or export MySQL Users from one machine to another. The following SQL query will show your users:&lt;/div&gt;&lt;div style=&quot;border-width: 0px; font-family: inherit; font-size: 12px; font-style: inherit; font-weight: inherit; margin: 0px 0px 1.5em; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;b style=&quot;font-weight: bold;&quot;&gt;SELECT DISTINCT CONCAT (‘show grants for `’, user, ‘`@`’, host, ‘`;’) AS query FROM mysql.user;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;border-width: 0px; font-family: inherit; font-size: 12px; font-style: inherit; font-weight: inherit; margin: 0px 0px 1.5em; padding: 0px; vertical-align: baseline;&quot;&gt;In my case on my test server, this shows:&lt;/div&gt;&lt;div style=&quot;border-width: 0px; font-family: inherit; font-size: 12px; font-style: inherit; font-weight: inherit; margin: 0px 0px 1.5em; padding: 0px; vertical-align: baseline;&quot;&gt;SHOW GRANTS FOR ‘root’@’127.0.0.1′;&lt;br /&gt;
SHOW GRANTS FOR ‘debian-sys-maint’@&#39;localhost’;&lt;br /&gt;
SHOW GRANTS FOR ‘root’@&#39;localhost’;&lt;/div&gt;&lt;div style=&quot;border-width: 0px; font-family: inherit; font-size: 12px; font-style: inherit; font-weight: inherit; margin: 0px 0px 1.5em; padding: 0px; vertical-align: baseline;&quot;&gt;Now, I’ll need to execute each one of these as separate statements. The output of&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b style=&quot;font-weight: bold;&quot;&gt;SHOW GRANTS FOR ‘root’@&#39;localhost’;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;is:&lt;/div&gt;&lt;div style=&quot;border-width: 0px; font-family: inherit; font-size: 12px; font-style: inherit; font-weight: inherit; margin: 0px 0px 1.5em; padding: 0px; vertical-align: baseline;&quot;&gt;GRANT ALL PRIVILEGES ON *.* TO ‘root’@&#39;localhost’ IDENTIFIED BY PASSWORD ‘*XXX…XXX’ WITH GRANT OPTION;&lt;/div&gt;&lt;div style=&quot;border-width: 0px; font-family: inherit; font-size: 12px; font-style: inherit; font-weight: inherit; margin: 0px 0px 1.5em; padding: 0px; vertical-align: baseline;&quot;&gt;Copy and paste each ‘GRANT’ statement to your new SQL server, with the hashed password intact and you should be ready to go.&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://abdulzahra-alameri-php.blogspot.com/feeds/3128206708927816241/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://abdulzahra-alameri-php.blogspot.com/2011/03/how-to-copy-export-mysql-user.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3932080116325211990/posts/default/3128206708927816241'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3932080116325211990/posts/default/3128206708927816241'/><link rel='alternate' type='text/html' href='http://abdulzahra-alameri-php.blogspot.com/2011/03/how-to-copy-export-mysql-user.html' title='How to copy export mySQL user priviledges'/><author><name>Abdul Zahra Al Ameri</name><uri>http://www.blogger.com/profile/16930336258404396441</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXoqssOhhRJKC36bZ0CJtGsg5nuarPlr4IerH_0kFBkpk_YNPxkfIWFoyL0M351NtBRxXjSYguz0iD9Tw-Y_o5aTgyHDQ9hSsr8A78WZ2l8dGvLaFgi4l9UmPR5Vsmk4w/s220/drinktea-medium.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3932080116325211990.post-6562546720581969941</id><published>2011-03-20T18:16:00.000-07:00</published><updated>2011-03-20T18:16:53.126-07:00</updated><title type='text'>Lowercase and Uppercase in Perl</title><content type='html'>&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td background=&quot;./images/ds.jpg&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;/strong&gt;Lowercase and Uppercase in Perl&lt;/span&gt;&lt;/td&gt;&lt;td background=&quot;./images/ds.jpg&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;All the programming languages has functions/methods to convert case to upper or lowercase.&lt;br /&gt;
Perl has lc for lowercase, uc for uppercase, ucfirst for first character to be converted to uppercase. etc...&lt;br /&gt;
Let see some examples :&lt;br /&gt;
&lt;strong&gt;#!/usr/bin/perl -w&lt;br /&gt;
$name = &quot;firat serkan atagun&quot;;&lt;br /&gt;
$ucname= uc ($name);&lt;br /&gt;
$lcname = lc ($name);&lt;br /&gt;
$ucfname = ucfirst ($name);&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;print $name.&quot;\n&quot;.$ucname.&quot;\n&quot;.$lcname.&quot;\n&quot;.$ucfname;&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
The output will be : &lt;br /&gt;
&lt;strong&gt;firat serkan atagun&lt;br /&gt;
firat serkan atagun&lt;br /&gt;
FIRAT SERKAN ATAGUN&lt;br /&gt;
Firat serkan atagun&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
uc &lt;/strong&gt;function is used for converting strings in to uppercase.&lt;br /&gt;
&lt;strong&gt;lc &lt;/strong&gt;function is used for converting strings in to lowercase&lt;br /&gt;
&lt;strong&gt;ucfirst&lt;/strong&gt; function is used for converting the first chracter of the string to uppercase.&lt;br /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://abdulzahra-alameri-php.blogspot.com/feeds/6562546720581969941/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://abdulzahra-alameri-php.blogspot.com/2011/03/lowercase-and-uppercase-in-perl.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3932080116325211990/posts/default/6562546720581969941'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3932080116325211990/posts/default/6562546720581969941'/><link rel='alternate' type='text/html' href='http://abdulzahra-alameri-php.blogspot.com/2011/03/lowercase-and-uppercase-in-perl.html' title='Lowercase and Uppercase in Perl'/><author><name>Abdul Zahra Al Ameri</name><uri>http://www.blogger.com/profile/16930336258404396441</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXoqssOhhRJKC36bZ0CJtGsg5nuarPlr4IerH_0kFBkpk_YNPxkfIWFoyL0M351NtBRxXjSYguz0iD9Tw-Y_o5aTgyHDQ9hSsr8A78WZ2l8dGvLaFgi4l9UmPR5Vsmk4w/s220/drinktea-medium.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3932080116325211990.post-3189868354362785439</id><published>2011-03-15T18:01:00.000-07:00</published><updated>2011-03-15T18:01:34.324-07:00</updated><title type='text'>Using the Perl rand() function</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;h2 class=&quot;POD_HEAD1&quot;&gt;&lt;a href=&quot;&quot; name=&quot;Using_the_Perl_rand_&quot;&gt;Using the Perl rand() function&lt;/a&gt;&lt;/h2&gt;&lt;h3 class=&quot;POD_HEAD2&quot;&gt;&lt;a href=&quot;&quot; name=&quot;Introduction&quot;&gt;Introduction&lt;/a&gt;&lt;/h3&gt;&lt;div class=&quot;POD_TEXT&quot;&gt; The &lt;code&gt;rand()&lt;/code&gt; function is used to generate random numbers.  By  default it generates a number between 0 and 1, however you can pass it a  maximum and it will generate numbers between 0 and that number. &lt;/div&gt;&lt;h3 class=&quot;POD_HEAD2&quot;&gt;&lt;a href=&quot;&quot; name=&quot;Example_1_Between_0_&quot;&gt;Example 1. Between 0 and 1&lt;/a&gt;&lt;/h3&gt;&lt;div class=&quot;POD_TEXT&quot;&gt; To generate a random decimal number between 0 and 1, use &lt;code&gt;rand()&lt;/code&gt; without any parameters. &lt;/div&gt;&lt;pre class=&quot;POD_VERBATIM&quot;&gt;#!/usr/bin/perl
  use strict;
  use warnings;

  my $random_number = rand();

  print $random_number . &quot;\n&quot;;&lt;/pre&gt;&lt;div class=&quot;POD_TEXT&quot;&gt; This will give you a random number, like: &lt;/div&gt;&lt;pre class=&quot;POD_OUTPUT&quot;&gt;0.521563085335405&lt;/pre&gt;&lt;h3 class=&quot;POD_HEAD2&quot;&gt;&lt;a href=&quot;&quot; name=&quot;Example_2_A_bigger_r&quot;&gt;Example 2. A bigger range of numbers&lt;/a&gt;&lt;/h3&gt;&lt;div class=&quot;POD_TEXT&quot;&gt; Quite often you don&#39;t want a number between 0 and 1, but you want a bigger range of numbers.  If you pass &lt;code&gt;rand()&lt;/code&gt;  a maximum, it will return a decimal number between 0 and that number.   Our example below generates a random number between 0 and 100. &lt;/div&gt;&lt;pre class=&quot;POD_VERBATIM&quot;&gt;#!/usr/bin/perl
  use strict;
  use warnings;

  my $range = 100;

  my $random_number = rand($range);

  print $random_number . &quot;\n&quot;;&lt;/pre&gt;&lt;div class=&quot;POD_TEXT&quot;&gt; The program will produce something like: &lt;/div&gt;&lt;pre class=&quot;POD_OUTPUT&quot;&gt;34.0500569277541&lt;/pre&gt;&lt;h3 class=&quot;POD_HEAD2&quot;&gt;&lt;a href=&quot;&quot; name=&quot;Example_3_A_random_i&quot;&gt;Example 3. A random integer&lt;/a&gt;&lt;/h3&gt;&lt;div class=&quot;POD_TEXT&quot;&gt; To generate a random integer, convert the output from rand to an integer, as follows: &lt;/div&gt;&lt;pre class=&quot;POD_VERBATIM&quot;&gt;#!/usr/bin/perl
  use strict;
  use warnings;

  my $range = 100;

  my $random_number = int(rand($range));

  print $random_number . &quot;\n&quot;;&lt;/pre&gt;&lt;div class=&quot;POD_TEXT&quot;&gt; This program gives you an integer from 0 to 99 inclusive: &lt;/div&gt;&lt;pre class=&quot;POD_OUTPUT&quot;&gt;68&lt;/pre&gt;&lt;h3 class=&quot;POD_HEAD2&quot;&gt;&lt;a href=&quot;&quot; name=&quot;Example_4_With_an_of&quot;&gt;Example 4. With an offset&lt;/a&gt;&lt;/h3&gt;&lt;div class=&quot;POD_TEXT&quot;&gt; To generate a random number between, for example, 100 and 150, simply  work out the range and add the minimum value to your random number. &lt;/div&gt;&lt;pre class=&quot;POD_VERBATIM&quot;&gt;#!/usr/bin/perl
  use strict;
  use warnings;

  my $range = 50;
  my $minimum = 100;

  my $random_number = int(rand($range)) + $minimum;

  print $random_number . &quot;\n&quot;;&lt;/pre&gt;&lt;pre class=&quot;POD_VERBATIM&quot;&gt;&lt;iframe align=&quot;left&quot; frameborder=&quot;0&quot; marginheight=&quot;0&quot; marginwidth=&quot;0&quot; scrolling=&quot;no&quot; src=&quot;http://rcm.amazon.com/e/cm?t=imamhussainyoutf-20&amp;amp;o=1&amp;amp;p=8&amp;amp;l=bpl&amp;amp;asins=0596000278&amp;amp;fc1=000000&amp;amp;IS2=1&amp;amp;lt1=_blank&amp;amp;m=amazon&amp;amp;lc1=0000FF&amp;amp;bc1=000000&amp;amp;bg1=FFFFFF&amp;amp;f=ifr&quot; style=&quot;height: 245px; padding-right: 10px; padding-top: 5px; width: 131px;&quot;&gt;&lt;/iframe&gt;&lt;/pre&gt;&lt;pre class=&quot;POD_VERBATIM&quot;&gt;&lt;iframe align=&quot;left&quot; frameborder=&quot;0&quot; marginheight=&quot;0&quot; marginwidth=&quot;0&quot; scrolling=&quot;no&quot; src=&quot;http://rcm.amazon.com/e/cm?t=imamhussainyoutf-20&amp;amp;o=1&amp;amp;p=8&amp;amp;l=bpl&amp;amp;asins=0596520107&amp;amp;fc1=000000&amp;amp;IS2=1&amp;amp;lt1=_blank&amp;amp;m=amazon&amp;amp;lc1=0000FF&amp;amp;bc1=000000&amp;amp;bg1=FFFFFF&amp;amp;f=ifr&quot; style=&quot;height: 245px; padding-right: 10px; padding-top: 5px; width: 131px;&quot;&gt;&lt;/iframe&gt;&lt;/pre&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://abdulzahra-alameri-php.blogspot.com/feeds/3189868354362785439/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://abdulzahra-alameri-php.blogspot.com/2011/03/using-perl-rand-function.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3932080116325211990/posts/default/3189868354362785439'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3932080116325211990/posts/default/3189868354362785439'/><link rel='alternate' type='text/html' href='http://abdulzahra-alameri-php.blogspot.com/2011/03/using-perl-rand-function.html' title='Using the Perl rand() function'/><author><name>Abdul Zahra Al Ameri</name><uri>http://www.blogger.com/profile/16930336258404396441</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXoqssOhhRJKC36bZ0CJtGsg5nuarPlr4IerH_0kFBkpk_YNPxkfIWFoyL0M351NtBRxXjSYguz0iD9Tw-Y_o5aTgyHDQ9hSsr8A78WZ2l8dGvLaFgi4l9UmPR5Vsmk4w/s220/drinktea-medium.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3932080116325211990.post-1989830207876716507</id><published>2011-03-15T17:54:00.000-07:00</published><updated>2011-03-15T17:54:07.981-07:00</updated><title type='text'>How to connect in Perl to MySQL database</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&amp;nbsp;&lt;span style=&quot;font-size: x-large;&quot;&gt;How to connect in Perl to MySQL database&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
#!/usr/bin/perl&lt;br /&gt;
&lt;br /&gt;
# PERL MODULE&lt;br /&gt;
use Mysql;&lt;br /&gt;
&lt;br /&gt;
# MYSQL CONFIG VARIABLES&lt;br /&gt;
# MYSQL CONFIG VARIABLES&lt;br /&gt;
$host = &quot;localhost&quot;;&lt;br /&gt;
$database = &quot;store&quot;;&lt;br /&gt;
$tablename = &quot;inventory&quot;;&lt;br /&gt;
$user = &quot;username&quot;;&lt;br /&gt;
$pw = &quot;password&quot;;&lt;br /&gt;
&lt;br /&gt;
# PERL CONNECT()&lt;br /&gt;
$connect = Mysql-&amp;gt;connect($host, $database, $user, $pw);&lt;br /&gt;
&lt;br /&gt;
# SELECT DB&lt;br /&gt;
$connect-&amp;gt;selectdb($database);&lt;br /&gt;
&lt;br /&gt;
# LISTTABLES()&lt;br /&gt;
@tables = $db-&amp;gt;listtables;&lt;br /&gt;
&lt;br /&gt;
# PRINT EACH TABLE NAME&lt;br /&gt;
@tables = $connect-&amp;gt;listtables;&lt;br /&gt;
foreach $table (@tables) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; print &quot;$table&lt;br /&gt;
&quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;iframe align=&quot;left&quot; frameborder=&quot;0&quot; marginheight=&quot;0&quot; marginwidth=&quot;0&quot; scrolling=&quot;no&quot; src=&quot;http://rcm.amazon.com/e/cm?t=imamhussainyoutf-20&amp;amp;o=1&amp;amp;p=8&amp;amp;l=bpl&amp;amp;asins=0596005431&amp;amp;fc1=000000&amp;amp;IS2=1&amp;amp;lt1=_blank&amp;amp;m=amazon&amp;amp;lc1=0000FF&amp;amp;bc1=000000&amp;amp;bg1=FFFFFF&amp;amp;f=ifr&quot; style=&quot;height: 245px; padding-right: 10px; padding-top: 5px; width: 131px;&quot;&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;br /&gt;
# DEFINE A MySQL QUERY&lt;br /&gt;
$sqlstr = &quot;SELECT * FROM $tablename&quot;;&lt;br /&gt;
$sqlstr=&quot;select id, captcha_question from captcha where id=&#39;$captch_id&#39; LIMIT 1&quot;;&lt;br /&gt;
&lt;br /&gt;
# EXECUTE THE QUERY&lt;br /&gt;
$execute = $connect-&amp;gt;query($sqlstr);&lt;br /&gt;
&lt;br /&gt;
$rownumber = $execute-&amp;gt;numrows();&lt;br /&gt;
$fieldnumber = $execute-&amp;gt;numfields();&lt;br /&gt;
&lt;br /&gt;
# PRINT THE RESULTS&lt;br /&gt;
print $rownumber.&quot;&lt;br /&gt;
&quot;;&lt;br /&gt;
print $fieldnumber.&quot;&lt;br /&gt;
&quot;;&lt;br /&gt;
&lt;br /&gt;
# HTML TABLE&lt;br /&gt;
print &quot;&lt;br /&gt;
&lt;table border=&quot;1&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;
&lt;th&gt;id&lt;/th&gt;
&lt;th&gt;product&lt;/th&gt;
&lt;th&gt;quantity&lt;/th&gt;&lt;/tr&gt;
&quot;;

# FETCHROW ARRAY

while (@results = $execute-&amp;gt;fetchrow()) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; print &quot;
&lt;tr&gt;&lt;td&gt;&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; .$results[0].&quot;&lt;/td&gt;&lt;td&gt;&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; .$results[1].&quot;&lt;/td&gt;&lt;td&gt;&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; .$results[2].&quot;&lt;/td&gt;&lt;/tr&gt;
&quot;;
}

print &quot;&lt;/tbody&gt;&lt;/table&gt;&quot;;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://abdulzahra-alameri-php.blogspot.com/feeds/1989830207876716507/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://abdulzahra-alameri-php.blogspot.com/2011/03/how-to-connect-in-perl-to-mysql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3932080116325211990/posts/default/1989830207876716507'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3932080116325211990/posts/default/1989830207876716507'/><link rel='alternate' type='text/html' href='http://abdulzahra-alameri-php.blogspot.com/2011/03/how-to-connect-in-perl-to-mysql.html' title='How to connect in Perl to MySQL database'/><author><name>Abdul Zahra Al Ameri</name><uri>http://www.blogger.com/profile/16930336258404396441</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXoqssOhhRJKC36bZ0CJtGsg5nuarPlr4IerH_0kFBkpk_YNPxkfIWFoyL0M351NtBRxXjSYguz0iD9Tw-Y_o5aTgyHDQ9hSsr8A78WZ2l8dGvLaFgi4l9UmPR5Vsmk4w/s220/drinktea-medium.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3932080116325211990.post-3586234514202682962</id><published>2011-02-21T21:32:00.001-08:00</published><updated>2011-02-21T21:32:55.957-08:00</updated><title type='text'>Advanced email in PHP</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #555555; font-family: Verdana,Geneva,Arial,Helvetica,sans-serif; font-size: x-small;&quot;&gt;&lt;h1 id=&quot;title&quot; style=&quot;color: #003366; font: 400 28px Verdana,&#39;Trebuchet MS&#39;,Arial,Helvetica,sans-serif; letter-spacing: -0.05em; margin: 20px 0px 10px; position: relative; text-indent: 0px; width: 1060px;&quot;&gt;Advanced email in PHP&lt;/h1&gt;&lt;div id=&quot;print-articledetail&quot; style=&quot;color: black; font-family: Georgia,Times,&#39;Times New Roman&#39;,serif;&quot;&gt;&lt;div id=&quot;bio&quot; style=&quot;clear: both; float: right; margin: 31px 0px 0px 21px; padding: 21px; width: 265px;&quot;&gt;&lt;div class=&quot;boxes&quot; style=&quot;background-color: #fcfcfa; border: 1pt solid rgb(192, 208, 224); padding-bottom: 2em;&quot;&gt;&lt;h3 style=&quot;background-color: transparent; color: #cccccc; font-family: &#39;Trebuchet MS&#39;,Arial,Helvetica,sans-serif; font-size: 21px; margin: 10px;&quot;&gt;About the Author&lt;/h3&gt;&lt;h4 style=&quot;font: bold 100% Verdana,Arial,Helvetica,sans-serif; margin: 1em ! important;&quot;&gt;Kevin Yank&lt;/h4&gt;&lt;div style=&quot;font-size: x-small; line-height: 15px; margin-bottom: 1em ! important; margin-left: 20px; margin-right: 1em ! important; margin-top: 1em ! important;&quot;&gt;&lt;img alt=&quot;author_kev1&quot; height=&quot;67&quot; src=&quot;http://sitepointstatic.com/graphics/1kev.jpg&quot; style=&quot;border: 0px none rgb(255, 255, 255); float: left; margin-right: 1em;&quot; width=&quot;56&quot; /&gt;Kevin began developing for the Web in 1995 and is a highly respected technical author. He wrote&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;a class=&quot;sublink&quot; href=&quot;http://www.sitepoint.com/books/phpmysql1/&quot; rel=&quot;external&quot; style=&quot;background-color: transparent; color: #0066cc;&quot;&gt;&lt;em&gt;Build your own Database Driven Website using PHP and MySQL&lt;/em&gt;&lt;/a&gt;, a practical step-by-step guide published by SitePoint, and he&#39;s co-author of the&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;a class=&quot;sublink&quot; href=&quot;http://www.sitepoint.com/newsletter/&quot; style=&quot;background-color: transparent; color: #0066cc;&quot;&gt;SitePoint Tech Times&lt;/a&gt;, a bi-weekly newsletter for technically-minded web developers. Kev believes that any good webmaster should have seen at least one episode of&lt;em&gt;MacGyver&lt;/em&gt;.&lt;/div&gt;&lt;div style=&quot;font-size: x-small; line-height: 15px; margin-bottom: 1em ! important; margin-left: 20px; margin-right: 1em ! important; margin-top: 1em ! important;&quot;&gt;&lt;a href=&quot;http://www.sitepoint.com/articlelist/48&quot; style=&quot;background-color: transparent; color: #0066cc;&quot;&gt;View all articles by Kevin Yank...&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;font-size: x-small; line-height: 15px; margin-bottom: 1em ! important; margin-left: 20px; margin-right: 1em ! important; margin-top: 1em ! important;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;by&quot; style=&quot;font-size: 18px; line-height: 27px; margin: 0px;&quot;&gt;By:&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://www.sitepoint.com/articlelist/48&quot; style=&quot;background-color: transparent; color: #0066cc;&quot; title=&quot;Find out more about this author&quot;&gt;Kevin Yank&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;date&quot; style=&quot;color: #666666; font-size: 18px; line-height: 27px; margin: 0px;&quot;&gt;February 13th, 2002&lt;/div&gt;&lt;div class=&quot;rating&quot; style=&quot;font-size: 18px; line-height: 27px; margin: 0px;&quot;&gt;Reader Rating: 9&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;&lt;strong&gt;I wish I could remember the very first email message I ever sent. Unfortunately, the truth is that I&#39;ve come to take email for granted; for instance, I easily send more email messages than I make phone calls. Because the novelty has long since worn off, the memory of that first email is as lost to me as my first phone call; but I doubt my sense of wonder was any less complete at the time. To someone who has never seen email in action before, that first message can be magical.&lt;/strong&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;In this article, I&#39;ll try to recapture some of that magic for those of you who have never created a Web site that sends email messages. We&#39;ll see how the PHP server-side scripting language may be set up to send email, and explore how to send complex message types such as HTML email or emails with file attachments.&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;&lt;strong&gt;Note:&lt;/strong&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;This article was written back when things like HTML email and file attachments were a lot more difficult to do in PHP than they are today. Before you dive into the from-scratch solutions presented in this article, you might consider investigating&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;a class=&quot;sublink&quot; href=&quot;http://phpmailer.sourceforge.net/&quot; style=&quot;background-color: transparent; color: #0066cc;&quot;&gt;PHPMailer&lt;/a&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;tiny&quot;&gt;[1]&lt;/span&gt;, a free library for PHP that provides all of these features with minimal hair-pulling and gnashing of teeth.&lt;/div&gt;&lt;h5 style=&quot;border-bottom: 1px dotted rgb(192, 208, 224); font-family: Verdana,Geneva,Arial,Helvetica,sans-serif; font-size: medium; margin: 20px 0px; padding-bottom: 0.3em;&quot;&gt;PHP Email Setup&lt;/h5&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;Before we can send email with PHP, we need to set it up to do so, just as you need to set up your email program before it can send messages. Configuration for sending email in PHP is done with the&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;php.ini&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;file, so open up your Web server&#39;s&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;php.ini&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;in whichever editor you normally use.&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;If you don&#39;t run your own server, but instead have a PHP-equipped Web host, you can safely assume that everything in this section has been done for you, and skip ahead.&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;In the section entitled&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;[mail function]&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;in the&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;php.ini&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;file, you&#39;ll find three settings:&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;SMTP&lt;/code&gt;,&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;sendmail_from&lt;/code&gt;, and&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;sendmail_path&lt;/code&gt;. If your server runs on a Windows machine, you&#39;ll want to set the&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;SMTP&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;option to point to your SMTP server (or your ISP&#39;s SMTP server, if you&#39;re setting up PHP on your home machine). If instead you&#39;re setting up PHP on a Linux (or other Unix-based OS) server, you&#39;ll want to set the&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;sendmail_path&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;option to point to the&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;sendmail&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;program on your server, passing it the&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;-t&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;option. You can use the SMTP option in Linux instead if you don&#39;t have&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;sendmail&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;set up.&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;In either case, you&#39;ll want to set the&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;sendmail_from&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;option to your email address, or whichever address you&#39;d like to appear as the default &#39;from&#39; address for emails sent from PHP scripts.&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;Here&#39;s how the section might look on a typical Windows server, or on a Linux server without sendmail:&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;[mail function]&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
; Setup for Windows systems&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
SMTP =&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;em&gt;smtp.my.isp.net&lt;/em&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
sendmail_from =&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;em&gt;me@myserver.com&lt;/em&gt;&lt;/code&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;And here&#39;s how it might look on a Linux server with sendmail:&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;[mail function]&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
; Setup for Linux systems&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
sendmail_path = /usr/sbin/sendmail -t&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
sendmail_from = me@myserver.com&lt;/code&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;With those settings in place, restart your Web server and you&#39;re ready to go!&lt;/div&gt;&lt;h5 style=&quot;border-bottom: 1px dotted rgb(192, 208, 224); font-family: Verdana,Geneva,Arial,Helvetica,sans-serif; font-size: medium; margin: 20px 0px; padding-bottom: 0.3em;&quot;&gt;Sending Plain Email&lt;/h5&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;It doesn&#39;t come much easier than the procedure to send plain text email in PHP. In fact, you can do it in just one line in a PHP script:&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;mail(&#39;recipient@some.net&#39;, &#39;Subject&#39;, &#39;Your message here.&#39;); &lt;br /&gt;
?&amp;gt;&lt;/code&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;The above line would send an email message to&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;recipient@some.net&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;with &#39;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;Subject&lt;/code&gt;&#39; as the subject line and &#39;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;Your message here.&lt;/code&gt;&#39; as the message body. As you can see, PHP&#39;s&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;mail&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;function makes sending email exceedingly simple, but there are a few advanced tricks we can use to get more out of this simple function.&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;First of all, if the mail system you configured in your&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;php.ini&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;file rejects a message you try to send (for example, if the &#39;to&#39; address is not a valid email address), this function will display an error message in the user&#39;s browser. Like most PHP functions, however, error messages may be suppressed by preceding the function name with an @ symbol. Combine this with the fact that the mail function returns either true or false depending on whether the email was accepted by the mail sending system, and you have a formula to send email with appropriate error checking:&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;if (@mail($to, $subject, $message)) { &lt;br /&gt;
&amp;nbsp;echo(&#39;&lt;/code&gt;&lt;/div&gt;Mail sent successfully.&lt;br /&gt;
&#39;); &lt;br /&gt;
} else { &lt;br /&gt;
&amp;nbsp;echo(&#39;Mail could not be sent.&lt;br /&gt;
&#39;); &lt;br /&gt;
} &lt;br /&gt;
?&amp;gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;Note that just because an email message could be sent doesn&#39;t guarantee it will arrive at its destination. An email address can be valid (i.e. correctly formed) but not actually exist. For instance, you can successfully send a message to&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;nonexistant.user@hotmail.com&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;-- that is, the mail function will return true -- but the message will bounce because no such user exists. PHP provides no built-in means of detecting when this happens.&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;When you want to send a message to multiple recipients, you can just list their email addresses one after another, separated by commas, in the first parameter. For example:&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;mail(&#39;recipient1@some.net, recipient2@some.net&#39;, &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &#39;An email to two people&#39;, &#39;Message goes here.&#39;); &lt;br /&gt;
?&amp;gt;&lt;/code&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;That about covers the basics of the&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;mail&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;function; now let&#39;s really get fancy and explore mail headers and what we can do with them!&lt;/div&gt;&lt;h5 style=&quot;border-bottom: 1px dotted rgb(192, 208, 224); font-family: Verdana,Geneva,Arial,Helvetica,sans-serif; font-size: medium; margin: 20px 0px; padding-bottom: 0.3em;&quot;&gt;HTML Email and Other Headers&lt;/h5&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;So now you can send email from your PHP scripts. How exciting! Although I&#39;m sure you&#39;re already drunk with power, would you like to know how to send HTML email too? Of&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;em&gt;course&lt;/em&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;you would!&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;To understand HTML email, first you need to understand mail headers. Any given email message is made up of two parts: the headers and the message body. Here&#39;s how a simple message looks when your email program fetches it from your ISP:&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;Return-Path: &lt;sender@elsewhere.com&gt; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
Delivered-To: you@some.net &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
Received: ...several lines like this... &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
From: Sender &lt;sender@elsewhere.com&gt; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
To: You &lt;you@some.net&gt; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
Subject: A Simple Message &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
Date: Mon, 11 Feb 2002 16:08:19 -0500 &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
Organization: Sender&#39;s Company &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
X-Mailer: Microsoft Outlook, Build 10.0.2616 &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
Hi there! &lt;tap&gt; &lt;tap&gt; Is this thing on?&lt;/tap&gt;&lt;/tap&gt;&lt;/you@some.net&gt;&lt;/sender@elsewhere.com&gt;&lt;/sender@elsewhere.com&gt;&lt;/code&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;Everything up to the blank line makes up the headers for this message. In actual fact, most email messages will have many more header lines than this; however, to keep our focus I trimmed this example down to the bare essentials.&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;As you can see, every line of the headers begins with the name of the header (&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;From:&lt;/code&gt;,&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;To:&lt;/code&gt;,&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;Subject:&lt;/code&gt;,&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;Date:&lt;/code&gt;, etc.), followed by some value. Most headers are standardized, and have a specific meaning, either to your mail program or to the mail servers that were responsible for getting the message to you. Non-standard headers exist as well, and they all begin with&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;X-&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;(e.g.&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;X-Mailer:&lt;/code&gt;, a non-standard header, often appears to indicate the program that was used to send the message).&lt;/div&gt;&lt;q style=&quot;color: grey; display: block; font: italic 90%/150% Georgia,&#39;Palatino Linotype&#39;,Palatino,&#39;Times New Roman&#39;,Times,serif; margin: 10px 58px; padding: 0px 4px 0px 24px;&quot;&gt;&lt;strong&gt;NOTE:&lt;/strong&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;If a header&#39;s value needs more than one line, additional lines should begin with a space. We&#39;ll see an example of this in the next section.&lt;/q&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;As soon as your mail program gets to a blank line, it knows the headers are over and the rest of the email is the message body, which it should display. In this case, the message body is the last line above.&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;PHP&#39;s&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;mail&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;function lets you specify your own headers, which it adds to those it generates automatically to get your message where it needs to go. For example, the following call to the&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;mail&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;function will add an&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;X-Mailer:&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;header to the outgoing message, identifying PHP 4.x as the sending program:&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;&lt;br /&gt;
mail(&#39;recipient@some.net&#39;, &#39;Subject&#39;, &#39;Your message here.&#39;, &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &#39;X-Mailer: PHP 4.x&#39;); &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
?&amp;gt;&lt;/code&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;This optional fourth parameter is most often used to specify a &#39;from&#39; address other than the default specified in&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;php.ini&lt;/code&gt;. Let&#39;s add a From: header to do just that:&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;&lt;br /&gt;
mail(&#39;recipient@some.net&#39;, &#39;Subject&#39;, &#39;Your message here.&#39;, &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &quot;From: sender@some.net\nX-Mailer: PHP 4.x&quot;); &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
?&amp;gt;&lt;/code&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;Note that since headers each appear on a single line, we must separate our two headers with a new line character (&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;\n&lt;/code&gt;), which means I need to use double quotes around the header string (single quoted strings don&#39;t recognize special character codes like&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;\n&lt;/code&gt;).&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;Additional headers also let you assign names to email addresses by specifying them in the format&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;name &lt;email&gt;&lt;/email&gt;&lt;/code&gt;. Here&#39;s our example again, but this time with names &quot;The Sender&quot; and &quot;The Receiver&quot; attached to the relevant addresses:&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;&lt;br /&gt;
mail(&#39;recipient@some.net&#39;, &#39;Subject&#39;, &#39;Your message here.&#39;, &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &quot;To: The Receiver &lt;recipient@some.net&gt;\n&quot; . &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &quot;From: The Sender &lt;sender@some.net&gt;\n&quot; . &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &quot;X-Mailer: PHP 4.x&quot;); &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
?&amp;gt;&lt;/sender@some.net&gt;&lt;/recipient@some.net&gt;&lt;/code&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;Notice that to do this, we&#39;ve had to specify the&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;To:&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;header manually, since the first parameter of PHP&#39;s&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;mail&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;function doesn&#39;t support this more advanced address format. We must still list all the recipients of the message as bare email addresses in the first parameter, however.&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;The&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;cc:&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;and&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;Bcc:&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;headers provide the ability to send carbon copies and blind carbon copies of a message as well:&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;&lt;br /&gt;
mail(&#39;recipient@some.net, someone@some.net, metoo@some.net&#39;, &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &#39;Subject&#39;, &#39;Your message here.&#39;, &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &quot;To: The Receiver &lt;recipient@some.net&gt;\n&quot; . &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &quot;From: The Sender &lt;sender@some.net&gt;\n&quot; . &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &quot;cc: Interested &lt;someone@some.net&gt;\n&quot; . &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &quot;Bcc: Me Too &lt;metoo@some.net&gt;\n&quot; . &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &quot;X-Mailer: PHP 4.x&quot;); &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
?&amp;gt;&lt;/metoo@some.net&gt;&lt;/someone@some.net&gt;&lt;/sender@some.net&gt;&lt;/recipient@some.net&gt;&lt;/code&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;See how the email addresses of all recipients, be they actual addressees (To), carbon copies (Cc), or blind carbon copies (Bcc) are listed in the first parameter? This isn&#39;t documented anywhere, but in my testing I&#39;ve found that it&#39;s absolutely vital if you want the message to get to everyone it&#39;s supposed to, especially on Windows servers where PHP&#39;s&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;mail&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;function is especially sensitive.&lt;/div&gt;&lt;q style=&quot;color: grey; display: block; font: italic 90%/150% Georgia,&#39;Palatino Linotype&#39;,Palatino,&#39;Times New Roman&#39;,Times,serif; margin: 10px 58px; padding: 0px 4px 0px 24px;&quot;&gt;&lt;strong&gt;BUG ALERT:&lt;/strong&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;There are two apparent bugs in the PHP&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 13px;&quot;&gt;mail&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;function, which I&#39;ve observed as recently as PHP 4.1.0, that you must be aware of. First, the&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 13px;&quot;&gt;Cc:&lt;/code&gt;header must be typed &#39;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 13px;&quot;&gt;cc:&lt;/code&gt;&#39; (as above) or &#39;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 13px;&quot;&gt;CC:&lt;/code&gt;&#39;, that is, in either all-caps or low-caps. The mixed case version (&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 13px;&quot;&gt;Cc:&lt;/code&gt;) should work, but it doesn&#39;t. Secondly, on Windows servers, the&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 13px;&quot;&gt;Bcc:&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;header does not work as it should.&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 13px;&quot;&gt;Bcc:&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;recipients do get a copy of the message, but the&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 13px;&quot;&gt;Bcc:&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;headers are not stripped out of the message during sending, so recipients can see the&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 13px;&quot;&gt;Bcc:&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;receivers by looking at those lines in the headers.&lt;/q&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;What does all this have to do with HTML email, you ask? Well, a few special headers will cause the message body to be interpreted as HTML by email clients that support it:&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;&lt;br /&gt;
mail(&#39;recipient@some.net&#39;, &#39;Subject&#39;, &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &#39;&lt;/code&gt;&lt;/div&gt;Your &lt;i&gt;message&lt;/i&gt; here.&lt;br /&gt;
&#39;, &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &quot;To: The Receiver &lt;recipient@some.net&gt;\n&quot; . &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &quot;From: The Sender &lt;sender@some.net&gt;\n&quot; . &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &quot;MIME-Version: 1.0\n&quot; . &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &quot;Content-type: text/html; charset=iso-8859-1&quot;); &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
?&amp;gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;Note both the message in HTML format as well as the two new headers:&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;Mime-Version:&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;and&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;Content-type:&lt;/code&gt;.&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;The&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;MIME-Version:&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;header indicates that the standard extended mail format will be used (MIME stands for Multipurpose Internet Mail Extensions), which allows for messages to be sent content types other than plain text. The&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;Content-type:&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;header then specifies that the message with contain HTML (and sets the character set to the standard for that format).&lt;/div&gt;&lt;h5 style=&quot;border-bottom: 1px dotted rgb(192, 208, 224); font-family: Verdana,Geneva,Arial,Helvetica,sans-serif; font-size: medium; margin: 20px 0px; padding-bottom: 0.3em;&quot;&gt;Mixed Messages&lt;/h5&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;In life, it&#39;s rarely good to send mixed messages. At least, that&#39;s what my last girlfriend told me! When it comes to email, however, mixed messages offer a whole lot of power. A single email message can contain both text and HTML versions of your message. That makes it viewable in most any email program, and you don&#39;t sacrifice the power of HTML formatting for readers that are appropriately equipped.&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;Be aware that mixed messages have their weaknesses. First of all, since you&#39;re sending two versions of your message, the message will typically be a lot larger than it would be if you sent just one format or the other. Also note that old email programs that don&#39;t recognize the mixed message format may display both versions of the message as file attachments (one text, the other HTML).&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;Let&#39;s look at a simple example of a mixed email message, and then look at the PHP code to send it:&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;Date: Mon, 11 Feb 2002 16:08:19 -0500 &amp;nbsp; &lt;br /&gt;
To: The Receiver &lt;recipient@some.net&gt; &amp;nbsp; &lt;br /&gt;
From: The Sender &lt;sender@some.net&gt; &amp;nbsp; &lt;br /&gt;
Subject: A simple mixed message &amp;nbsp; &lt;br /&gt;
MIME-Version: 1.0 &amp;nbsp; &lt;br /&gt;
Content-Type: multipart/alternative; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;boundary=&quot;==Multipart_Boundary_xc75j85x&quot; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
This is a multi-part message in MIME format. &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
--==Multipart_Boundary_xc75j85x &amp;nbsp; &lt;br /&gt;
Content-Type: text/plain; charset=&quot;iso-8859-1&quot; &amp;nbsp; &lt;br /&gt;
Content-Transfer-Encoding: 7bit &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
This is the text portion of the mixed message. &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
--==Multipart_Boundary_xc75j85x &amp;nbsp; &lt;br /&gt;
Content-Type: text/html; charset=&quot;iso-8859-1&quot; &amp;nbsp; &lt;br /&gt;
Content-Transfer-Encoding: 7bit &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;/sender@some.net&gt;&lt;/recipient@some.net&gt;&lt;/code&gt;&lt;/div&gt;This is the &lt;b&gt;HTML portion&lt;/b&gt; of the mixed message.&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
--==Multipart_Boundary_xc75j85x--&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;After the initial, standard headers at the top of the message, we have the&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;MIME-Version: 1.0&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;header that enables the advanced email features we need. The&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;Content-Type:&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;header is where things start to get funky:&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;Content-Type: multipart/alternative; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;boundary=&quot;==Multipart_Boundary_xxc75885&quot;&lt;/code&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;We specify a content type of&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;multipart/alternative&lt;/code&gt;, which is the special type that allows us to send a message with two or more alternative versions of the message (from which the recipient&#39;s email program will pick the most suitable for display). In addition, we use the&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;Content-Type&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;header to set a&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;em&gt;boundary string&lt;/em&gt;.&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;To keep the header lines short, this part of the header appears on a second line (as mentioned in a note above, the second line must begin with one or more spaces to indicate that it&#39;s a continuation of the previous line).&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;In this case, I chose &quot;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;==Multipart_Boundary_xc75j85x&lt;/code&gt;&quot; as the boundary string. There is no special significance to this string, other than it is unlikely to appear as part of the message itself. I used characters like equals signs and underscores, and semi-random strings of letters and numbers to help ensure this. We then use this string to divide up our message into parts.&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;The text &quot;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;This is a multi-part message in MIME format.&lt;/code&gt;&quot; is included for the benefit of older mail programs, so that the user has some idea of why the email may not appear quite as expected. With that disclaimer out of the way, we use our boundary to mark the start of the first part of our message:&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;--==Multipart_Boundary_xc75j85x &amp;nbsp; &lt;br /&gt;
Content-Type: text/plain; charset=&quot;iso-8859-1&quot; &amp;nbsp; &lt;br /&gt;
Content-Transfer-Encoding: 7bit &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
This is the text portion of the mixed message.&lt;/code&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;Notice that we add two dashes (&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;--&lt;/code&gt;) to the beginning of the boundary string when we actually use it.&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;After the first boundary, we begin the text version of the message. Each part of the message begins with a couple of headers to indicate its content type and encoding. In the case of the text part, the content type is&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;text/plain&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;(with the standard character set,&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;iso-8859-1&lt;/code&gt;), and the encoding is&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;7bit&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;(plain ASCII text). A blank line marks the end of the headers, which are followed by the message body.&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;The HTML version then follows:&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;--==Multipart_Boundary_xc75j85x &amp;nbsp; &lt;br /&gt;
Content-Type: text/html; charset=&quot;iso-8859-1&quot; &amp;nbsp; &lt;br /&gt;
Content-Transfer-Encoding: 7bit &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;/code&gt;&lt;/div&gt;This is the &lt;b&gt;HTML portion&lt;/b&gt; of the mixed message.&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;The headers are almost identical to the text part, but this time we specify&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;text/html&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;as the content type. After the body of the HTML document, all that remains is the closing boundary, to which we add an extra two dashes on the end to mark the end of the message:&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;--==Multipart_Boundary_xc75j85x--&lt;/code&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;As you can see, mixed messages may look complicated, but they&#39;re actually pretty simple when you take a closer look. The only tricky part from the standpoint of a PHP developer who wants to send a message like this is the task of generating a boundary string.&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;Here&#39;s how I like to do it:&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;$semi_rand = md5(time()); &amp;nbsp; &lt;br /&gt;
$mime_boundary = &quot;==Multipart_Boundary_x{$semi_rand}x&quot;; &amp;nbsp; &lt;br /&gt;
?&amp;gt;&lt;/code&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;We take the current Unix timestamp (the number of seconds since January 1, 1970), as given by&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;time()&lt;/code&gt;, and use the MD5 algorithm to convert it to a semi-random string. This string is then used to make up part of the boundary string. Feel free to use whatever method you like to generate your boundary strings.&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;With all this in mind, you should be well-equipped to generate mixed messages in PHP. Since mixed messages are relatively uncommon, I&#39;ll leave the actual code for you to write as an exercise. This business of splitting up messages into parts with a boundary string is important, however, when it comes to file attachments -- the subject of our final section.&lt;/div&gt;&lt;h5 style=&quot;border-bottom: 1px dotted rgb(192, 208, 224); font-family: Verdana,Geneva,Arial,Helvetica,sans-serif; font-size: medium; margin: 20px 0px; padding-bottom: 0.3em;&quot;&gt;File Attachments&lt;/h5&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;File attachments work just like mixed email, except that a different content type is used for the message as a whole (&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;multipart/mixed&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;instead of&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;multipart/alternative&lt;/code&gt;), and there&#39;s a new&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;Content-Disposition&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;header that tells the email client how to handle each part of the message.&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;Let&#39;s write a PHP script that processes a form submission that contains an email message to be sent, possibly with a file attachment, and sends it out. I&#39;ll talk you through it line by line so that by the end you&#39;ll not only have a useful snippet of PHP code, but also an understanding of how file attachments work. You can&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;a class=&quot;sublink&quot; href=&quot;http://www.webmasterbase.com/examples/phpemail/phpemail.zip&quot; style=&quot;background-color: transparent; color: #0066cc;&quot;&gt;download the script&lt;/a&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;tiny&quot;&gt;[2]&lt;/span&gt;(and the form for it) if you want to try it out for yourself.&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;First, we grab the submitted values and place them in PHP variables. Most people have their servers set up to create global variables for submitted values automatically, but as of PHP 4.1 this is no longer the default, so we do it by hand just in case. Since we want to accept file attachments, it&#39;s safe to assume that the form will be submitted with a POST request:&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;&lt;br /&gt;
// Read POST request params into global vars &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
$to &amp;nbsp; &amp;nbsp; &amp;nbsp;= $_POST[&#39;to&#39;]; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
$from &amp;nbsp; &amp;nbsp;= $_POST[&#39;from&#39;]; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
$subject = $_POST[&#39;subject&#39;]; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
$message = $_POST[&#39;message&#39;];&lt;/code&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;File uploads in PHP 4.1 are placed in a special&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;$_FILES&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;array, so we fetch the values we need out of it:&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;// Obtain file upload vars &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
$fileatt &amp;nbsp; &amp;nbsp; &amp;nbsp;= $_FILES[&#39;fileatt&#39;][&#39;tmp_name&#39;]; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
$fileatt_type = $_FILES[&#39;fileatt&#39;][&#39;type&#39;]; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
$fileatt_name = $_FILES[&#39;fileatt&#39;][&#39;name&#39;];&lt;/code&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;For the sake of brevity, we&#39;ll assume that the required parameters (&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;$to&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;and&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;$from&lt;/code&gt;) now have valid values (email addresses) in them. Normally we would check their format with regular expressions.&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;Next, we use the&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;$from&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;value to begin building the extra headers for the email:&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;$headers = &quot;From: $from&quot;;&lt;/code&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;Next we check the&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;$fileatt&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;variable, which may or may not contain the path and filename to an uploaded file attachment. We use PHP&#39;s&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;is_uploaded_file&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;function to find out:&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;if (is_uploaded_file($fileatt)) { &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;// Read the file to be attached (&#39;rb&#39; = read binary) &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;$file = fopen($fileatt,&#39;rb&#39;); &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;$data = fread($file,filesize($fileatt)); &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;fclose($file);&lt;/code&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;Having read in the data for the file attachment, we need to set up the message headers to send a&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;multipart/mixed&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;message:&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;&amp;nbsp;// Generate a boundary string &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;$semi_rand = md5(time()); &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;$mime_boundary = &quot;==Multipart_Boundary_x{$semi_rand}x&quot;; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;// Add the headers for a file attachment &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;$headers .= &quot;\nMIME-Version: 1.0\n&quot; . &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;Content-Type: multipart/mixed;\n&quot; . &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot; boundary=\&quot;{$mime_boundary}\&quot;&quot;;&lt;/code&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;Now for the message body itself. This works just as we saw for the text part of a mixed message in the previous section:&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;&amp;nbsp;// Add a multipart boundary above the plain message &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;$message = &quot;This is a multi-part message in MIME format.\n\n&quot; . &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;--{$mime_boundary}\n&quot; . &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Content-Type: text/plain; charset=\&quot;iso-8859-1\&quot;\n&quot; . &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Content-Transfer-Encoding: 7bit\n\n&quot; . &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $message . &quot;\n\n&quot;;&lt;/code&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;Now, to allow for binary file types, we need to use Base64 encoding to convert the (possibly binary) file attachment data to a text-only format suitable for sending by email. All email programs in popular use support Base64 encoding of file attachments, so this is the best way to go. Fortunately, PHP provides a function for Base64 encoding:&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;&amp;nbsp;// Base64 encode the file data &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;$data = chunk_split(base64_encode($data));&lt;/code&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;We now have everything we need to write the portion of the message that contains the file attachment. Here&#39;s the code:&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;&amp;nbsp;// Add file attachment to the message &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;$message .= &quot;--{$mime_boundary}\n&quot; . &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;Content-Type: {$fileatt_type};\n&quot; . &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot; name=\&quot;{$fileatt_name}\&quot;\n&quot; . &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;Content-Disposition: attachment;\n&quot; . &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot; filename=\&quot;{$fileatt_name}\&quot;\n&quot; . &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;Content-Transfer-Encoding: base64\n\n&quot; . &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$data . &quot;\n\n&quot; . &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;--{$mime_boundary}--\n&quot;; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
}&lt;/code&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;That completes the modifications necessary to accommodate a file attachment. We can now send the message with a quick call to&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;mail&lt;/code&gt;:&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;// Send the message &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
$ok = @mail($to, $subject, $message, $headers); &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
if ($ok) { &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;echo &quot;&lt;/code&gt;&lt;/div&gt;Mail sent! Yay PHP!&lt;br /&gt;
&quot;; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
} else { &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;echo &quot;Mail could not be sent. Sorry!&lt;br /&gt;
&quot;; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
} &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
?&amp;gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;And that&#39;s how we send emails with file attachments in PHP!&lt;/div&gt;&lt;h5 style=&quot;border-bottom: 1px dotted rgb(192, 208, 224); font-family: Verdana,Geneva,Arial,Helvetica,sans-serif; font-size: medium; margin: 20px 0px; padding-bottom: 0.3em;&quot;&gt;Summary&lt;/h5&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;In this article, you probably learned a lot more about email than you ever wanted to know. That intimate knowledge about what makes email tick allowed us to do some pretty special things with PHP&#39;s deceptively simple&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-attachment: scroll; background-color: white; background-image: none; background-position: 0px 0px; color: #990000; font-family: &#39;Courier New&#39;,Courier,mono; font-size: 15px;&quot;&gt;mail&lt;/code&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;function.&lt;/div&gt;&lt;ul style=&quot;margin: 20px 0px; padding-left: 30px;&quot;&gt;&lt;li style=&quot;line-height: 19px;&quot;&gt;we learned how to manipulate email headers to play with the recipients of an email&lt;/li&gt;
&lt;li style=&quot;line-height: 19px;&quot;&gt;we saw the headers that permit you to send HTML email&lt;/li&gt;
&lt;li style=&quot;line-height: 19px;&quot;&gt;we combined the HTML and text versions of an email into a single, mixed message&lt;/li&gt;
&lt;/ul&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;and finally...&lt;/div&gt;&lt;ul style=&quot;margin: 20px 0px; padding-left: 30px;&quot;&gt;&lt;li style=&quot;line-height: 19px;&quot;&gt;we brought it all together with a couple of new tricks to send email messages with file attachments.&lt;/li&gt;
&lt;/ul&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;If you&#39;re in the mood for a challenge, try expanding the file attachment script in this article to allow for multiple file attachments, or to allow for an HTML message. If you&#39;re an object oriented PHP type, try developing a class that encapsulates the functionality we explored in this article (there are a number of such scripts available on the Internet if you&#39;re after something ready-made).&lt;/div&gt;&lt;div style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;If you&#39;re&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;em&gt;really&lt;/em&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;interested, check out the RFC for MIME extensions (&lt;a class=&quot;sublink&quot; href=&quot;http://www.ietf.org/rfc/rfc2045.txt&quot; rel=&quot;external&quot; style=&quot;background-color: transparent; color: #0066cc;&quot;&gt;RFC 2045&lt;/a&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;tiny&quot;&gt;[3]&lt;/span&gt;) to discover everything that email is capable of, then go wild!&lt;/div&gt;&lt;div class=&quot;tiny&quot; style=&quot;line-height: 19px; margin: 20px 0px;&quot;&gt;[1] http://phpmailer.sourceforge.net/&lt;br /&gt;
[2] http://www.webmasterbase.com/examples/phpemail/phpemail.zip&lt;br /&gt;
[3] http://www.ietf.org/rfc/rfc2045.txt&lt;/div&gt;&lt;/sender@some.net&gt;&lt;/recipient@some.net&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://abdulzahra-alameri-php.blogspot.com/feeds/3586234514202682962/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://abdulzahra-alameri-php.blogspot.com/2011/02/advanced-email-in-php.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3932080116325211990/posts/default/3586234514202682962'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3932080116325211990/posts/default/3586234514202682962'/><link rel='alternate' type='text/html' href='http://abdulzahra-alameri-php.blogspot.com/2011/02/advanced-email-in-php.html' title='Advanced email in PHP'/><author><name>Abdul Zahra Al Ameri</name><uri>http://www.blogger.com/profile/16930336258404396441</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXoqssOhhRJKC36bZ0CJtGsg5nuarPlr4IerH_0kFBkpk_YNPxkfIWFoyL0M351NtBRxXjSYguz0iD9Tw-Y_o5aTgyHDQ9hSsr8A78WZ2l8dGvLaFgi4l9UmPR5Vsmk4w/s220/drinktea-medium.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3932080116325211990.post-6735432657601686989</id><published>2011-02-20T15:48:00.000-08:00</published><updated>2011-02-20T15:48:42.356-08:00</updated><title type='text'>MySQL Security Checklist</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;MySQL Security Checklist&lt;iframe align=&quot;left&quot; frameborder=&quot;0&quot; marginheight=&quot;0&quot; marginwidth=&quot;0&quot; scrolling=&quot;no&quot; src=&quot;http://rcm.amazon.com/e/cm?t=imamhussainyoutf-20&amp;amp;o=1&amp;amp;p=8&amp;amp;l=bpl&amp;amp;asins=0764578014&amp;amp;fc1=000000&amp;amp;IS2=1&amp;amp;lt1=_blank&amp;amp;m=amazon&amp;amp;lc1=0000FF&amp;amp;bc1=000000&amp;amp;bg1=FFFFFF&amp;amp;f=ifr&quot; style=&quot;height: 245px; padding-right: 10px; padding-top: 5px; width: 131px;&quot;&gt;&lt;/iframe&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
Background&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 1.Read the MySQL security guidelines at http://dev.mysql.com/doc/mysql/en/Security.html.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 2.Visit http://www.mysql.com/products/mysql/ often, and check for updates.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 3.Know&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; your bugs! Check vulnerability databases such as SecurityFocus and ICAT&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; regularly for MySQL bugs, and (if you can stand the noise levels)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; subscribe to security mailing lists such as VulnWatch, BugTraq, and the&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MySQL mailing lists.&lt;br /&gt;
Operating System&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 1.Deploy IPTables (Linux), an IPSec filtering ruleset (Windows), or some other host-based firewall software on your MySQL servers.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 2.Use a low-privileged mysql account to run the MySQL daemon. This is the default on some platforms, but not others.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 3.Run mysqld with the --chroot option.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 4.Ensure that the MySQL user cannot access files&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outside of a limited set of directories. Specifically, the MySQL user&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; should be prohibited from reading operating system configuration files.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; In some cases you might want to prevent the MySQL user from being able&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; to modify the MySQL configuration files.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 5.Ensure that MySQL data files (normally residing&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; beneath the MySQL data directory) cannot be read by users other than&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; the root or Administrator account, and the account that MySQL is&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; running under.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 6.Plaintext credentials. Ensure that no user other&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; than the MySQL user can read any MySQL configuration and log files. The&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; files my.cnf, my.ini, and master.info commonly have plaintext usernames&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and passwords in them, and the query log file (if present) is likely to&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; contain passwords.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 7.Turn off unnecessary services or daemons.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 8.Make sure you don&#39;t have anything in your .mysql_history file.&lt;br /&gt;
MySQL Users&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 1.Set a &quot;strong&quot; password for the root@localhost account.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 2.Remove all non-root MySQL users.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 3.Rename the root MySQL user to something obscure.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 4.If remote connections are enabled, specify REQUIRE SSL in the GRANT statement used to set up the user.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 5.Create a MySQL user for each web application—or&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; possibly for each role within each web application. For instance, you&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; might have one MySQL user that you use to update tables, and another,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lower-privileged user that you use to &quot;select&quot; from tables.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 6.Ensure that MySQL users are restricted by IP&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; address as well as passwords. See section 5.4 of the MySQL manual, &quot;The&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MySQL Access Privilege System,&quot; for more information.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 7.Don&#39;t give accounts privileges that they don&#39;t absolutely need, especially File_priv, Grant_priv, and Super_priv.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 8.Never give anyone (other than root or whatever you call your root account) access to the mysql.user table.&lt;br /&gt;
MySQL Configuration&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 1.Enable logging via the --log option.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 2.Disable the LOAD DATA LOCAL INFILE command by adding set-variable=local-infile=0 to the my.cnf file.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 3.Remove any unused UDFs&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 4.If you&#39;re using only local connections, disable TCP/IP connections via the --skip-networking option.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 5.Depending on your operating system, and how your&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data directory is configured, you might want to disallow the use of&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; symbolic links via the skip-symbolic-links option.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 6.Remove the default test database.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 7.Ensure MySQL traffic is encrypted.&lt;br /&gt;
Routine Audit&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 1.Check your logs.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 2.Enumerate users and use the &quot;show grants&quot; statement regularly to see what privileges are granted to which users.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 3.Periodically do a quick check on password hashes.&lt;br /&gt;
&lt;iframe align=&quot;left&quot; frameborder=&quot;0&quot; marginheight=&quot;0&quot; marginwidth=&quot;0&quot; scrolling=&quot;no&quot; src=&quot;http://rcm.amazon.com/e/cm?t=imamhussainyoutf-20&amp;amp;o=1&amp;amp;p=8&amp;amp;l=bpl&amp;amp;asins=B0026OR358&amp;amp;fc1=000000&amp;amp;IS2=1&amp;amp;lt1=_blank&amp;amp;m=amazon&amp;amp;lc1=0000FF&amp;amp;bc1=000000&amp;amp;bg1=FFFFFF&amp;amp;f=ifr&quot; style=&quot;height: 245px; padding-right: 10px; padding-top: 5px; width: 131px;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://abdulzahra-alameri-php.blogspot.com/feeds/6735432657601686989/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://abdulzahra-alameri-php.blogspot.com/2011/02/mysql-security-checklist.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3932080116325211990/posts/default/6735432657601686989'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3932080116325211990/posts/default/6735432657601686989'/><link rel='alternate' type='text/html' href='http://abdulzahra-alameri-php.blogspot.com/2011/02/mysql-security-checklist.html' title='MySQL Security Checklist'/><author><name>Abdul Zahra Al Ameri</name><uri>http://www.blogger.com/profile/16930336258404396441</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXoqssOhhRJKC36bZ0CJtGsg5nuarPlr4IerH_0kFBkpk_YNPxkfIWFoyL0M351NtBRxXjSYguz0iD9Tw-Y_o5aTgyHDQ9hSsr8A78WZ2l8dGvLaFgi4l9UmPR5Vsmk4w/s220/drinktea-medium.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3932080116325211990.post-4625672959625621119</id><published>2011-01-20T21:15:00.000-08:00</published><updated>2011-01-20T21:15:10.317-08:00</updated><title type='text'>How to upload multiple files into mySLQ</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;a href=&quot;http://www.amazon.com/Head-First-MySQL-Lynn-Beighley/dp/0596006306&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot; target=&quot;_blank&quot;&gt;&lt;img alt=&quot;Head First PHP &amp;amp; MySQL&quot; class=&quot;AMZNimage&quot; height=&quot;60&quot; src=&quot;http://ecx.images-amazon.com/images/I/51HqlWBsv0L._SL75_.jpg&quot; width=&quot;52&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;http://www.amazon.com/PHP-Solutions-Dynamic-Design-Made/dp/1430232498&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot; target=&quot;_blank&quot;&gt;&lt;img alt=&quot;PHP Solutions: Dynamic Web Design Made Easy&quot; class=&quot;AMZNimage&quot; height=&quot;60&quot; src=&quot;http://ecx.images-amazon.com/images/I/51HHjwckplL._SL75_.jpg&quot; width=&quot;49&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;http://www.amazon.com/PHP-MySQL-Dynamic-Web-Sites/dp/032152599X&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot; target=&quot;_blank&quot;&gt;&lt;img alt=&quot;PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide&quot; class=&quot;AMZNimage&quot; height=&quot;60&quot; src=&quot;http://ecx.images-amazon.com/images/I/41NSMXp2hWL._SL75_.jpg&quot; width=&quot;46&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;http://www.amazon.com/PHP-MySQL-Web-Development-4th/dp/0672329166&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot; target=&quot;_blank&quot;&gt;&lt;img alt=&quot;PHP and MySQL Web Development (4th Edition)&quot; class=&quot;AMZNimage&quot; height=&quot;60&quot; src=&quot;http://ecx.images-amazon.com/images/I/51QGM-5H%2BLL._SL75_.jpg&quot; width=&quot;46&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;http://www.amazon.com/Learning-MySQL-JavaScript-Step-Step/dp/0596157134&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot; target=&quot;_blank&quot;&gt;&lt;img alt=&quot;Learning PHP, MySQL, and JavaScript: A Step-By-Step Guide to Creating Dynamic Websites (Animal Guide)&quot; class=&quot;AMZNimage&quot; height=&quot;60&quot; src=&quot;http://ecx.images-amazon.com/images/I/51UCPefBFjL._SL75_.jpg&quot; width=&quot;45&quot; /&gt;&lt;/a&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial,verdana,helvetica,sans-serif; font-size: 12px;&quot;&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;border-color: rgb(219, 219, 219); border-style: solid;&quot;&gt;&lt;tbody&gt;
&lt;tr align=&quot;LEFT&quot; style=&quot;background-color: white;&quot;&gt;&lt;td colspan=&quot;2&quot; style=&quot;padding: 0px 4px;&quot;&gt;By using this script you will be able to upload as many files as you want.&lt;br /&gt;
The code will check if file existes, limited extensions, file size, file selected ..etc.&lt;br /&gt;
For Q. E-mail/MSN: m(at)maaking.com.&lt;br /&gt;
&lt;br /&gt;
&lt;table bgcolor=&quot;#f5f4f4&quot; border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;border-color: rgb(200, 200, 200); border-style: solid; border-width: 0px 1px; padding: 6px;&quot;&gt;&lt;td&gt;&lt;div style=&quot;background-color: #e2e2e2; display: inline; float: right; position: relative; right: 0px;&quot;&gt;&lt;center&gt;&lt;/center&gt;&lt;div id=&quot;beacon_30a3814d59&quot; style=&quot;left: 0px; position: absolute; top: 0px; visibility: hidden;&quot;&gt;&lt;img alt=&quot;&quot; height=&quot;0&quot; src=&quot;http://i2.weber-sites.com/www/delivery/lg.php?bannerid=17&amp;amp;campaignid=7&amp;amp;zoneid=8&amp;amp;loc=1&amp;amp;referer=http%3A%2F%2Fwww.weberdev.com%2Fget_example-4224.html&amp;amp;cb=30a3814d59&quot; style=&quot;height: 0px; width: 0px;&quot; width=&quot;0&quot; /&gt;&lt;/div&gt;&lt;div style=&quot;height: 0px; overflow: hidden; position: absolute; width: 0px;&quot;&gt;&lt;img src=&quot;http://bid.openx.net/cm?wid=8a597a79-b8dc-4a57-8f09-689ca3e60a55&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff8000;&quot;&gt;###########################################&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;br /&gt;
#----------Upload Multiple Files----------#&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
#----------Multi-files Uploader-----------#&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
#-------------Multi-Uploader -------------#&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
###########################################&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;color: #ff8000;&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&lt;/span&gt;&lt;br /&gt;
/*=========================================\&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
Author&amp;nbsp; &amp;nbsp; &amp;nbsp; :&amp;nbsp; Mohammed Ahmed(M@@king)&amp;nbsp; &amp;nbsp; \\&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
Version&amp;nbsp; &amp;nbsp; &amp;nbsp;:&amp;nbsp; 1.0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; \\&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
Date Created:&amp;nbsp; Aug 20&amp;nbsp; 2005&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;\\&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
----------------------------&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; \\&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
Last Update:&amp;nbsp; &amp;nbsp;Aug 31 2005&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; \\&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
----------------------------&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; \\&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
Country&amp;nbsp; &amp;nbsp; :&amp;nbsp; &amp;nbsp;Palestine&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; \\&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;color: #ff8000;&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&lt;/span&gt;&lt;br /&gt;
City&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;:&amp;nbsp; &amp;nbsp;Gaza&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;\\&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
E-mail&amp;nbsp; &amp;nbsp; &amp;nbsp;:&amp;nbsp; &amp;nbsp;m@maaking.com&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; \\&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
MSN&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; :&amp;nbsp; &amp;nbsp;m@maaking.com&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; \\&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
AOL-IM&amp;nbsp; &amp;nbsp; &amp;nbsp;:&amp;nbsp; &amp;nbsp;maa2pal&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; \\&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
WWW&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; :&amp;nbsp; &amp;nbsp;http://www.maaking.com&amp;nbsp; &amp;nbsp; &amp;nbsp;\\&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
Mobile/SMS :&amp;nbsp; &amp;nbsp;00972-599-622235&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;\\&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; \\&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
===========================================\&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
------------------------------------------*/&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
//upload directory.&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
//change to fit your need eg. files, upload .... etc.&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$upload_dir&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;=&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot;images/&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff8000;&quot;&gt;//number of files to upload.&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$num_files&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;=&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff8000;&quot;&gt;//the file size in bytes.&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$size_bytes&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;51200&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff8000;&quot;&gt;//51200 bytes = 50KB.&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
//Extensions you want files uploaded limited to.&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$limitedext&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;= array(&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot;.gif&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot;.jpg&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot;.jpeg&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot;.png&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot;.txt&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot;.nfo&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot;.doc&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot;.rtf&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot;.htm&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot;.dmg&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot;.zip&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot;.rar&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot;.gz&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot;.exe&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;);&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #ff8000;&quot;&gt;//check if the directory exists or not.&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;if (!&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;is_dir&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot;$upload_dir&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;)) {&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; die (&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot;Error: The directory &lt;b&gt;($upload_dir)&lt;/b&gt; doesn&#39;t exist&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;);&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #ff8000;&quot;&gt;//check if the directory is writable.&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;if (!&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;is_writeable&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot;$upload_dir&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;)){&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; die (&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot;Error: The directory &lt;b&gt;($upload_dir)&lt;/b&gt; is NOT writable, Please CHMOD (777)&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;);&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: #ff8000;&quot;&gt;//if the form has been submitted, then do the upload process&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
//infact, if you clicked on (Upload Now!) button.&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;if (isset(&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$_POST&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&#39;upload_form&#39;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;])){&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;echo&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot;&lt;h3&gt;Upload results:&lt;/h3&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #ff8000;&quot;&gt;//do a loop for uploading files based on ($num_files) number of files.&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;for (&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$i&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;=&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$i&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;=&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$num_files&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$i&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;++) {&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #ff8000;&quot;&gt;//define variables to hold the values.&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$new_file&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;=&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$_FILES&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&#39;file&#39;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$i&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;];&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$file_name&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;=&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$new_file&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&#39;name&#39;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;];&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #ff8000;&quot;&gt;//to remove spaces from file name we have to replace it with &quot;_&quot;.&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$file_name&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;=&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;str_replace&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&#39; &#39;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;,&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&#39;_&#39;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;,&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$file_name&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;);&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$file_tmp&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;=&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$new_file&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&#39;tmp_name&#39;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;];&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$file_size&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;=&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$new_file&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&#39;size&#39;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;];&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #ff8000;&quot;&gt;#-----------------------------------------------------------#&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;# this code will check if the files was selected or not.&amp;nbsp; &amp;nbsp; #&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;#-----------------------------------------------------------#&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;if (!&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;is_uploaded_file&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$file_tmp&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;)) {&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff8000;&quot;&gt;//print error message and file number.&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;echo&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot;File $i: Not selected.&lt;br /&gt;
&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}else{&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #ff8000;&quot;&gt;#-----------------------------------------------------------#&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;# this code will check file extension&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;#&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;#-----------------------------------------------------------#&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$ext&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;=&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;strrchr&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$file_name&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&#39;.&#39;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;);&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (!&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;in_array&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;strtolower&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$ext&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;),&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$limitedext&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;)) {&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; echo&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot;File $i: ($file_name) Wrong file extension. &lt;br /&gt;
&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}else{&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #ff8000;&quot;&gt;#-----------------------------------------------------------#&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;# this code will check file size is correct&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;#&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;#-----------------------------------------------------------#&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;if (&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$file_size&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;&amp;gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$size_bytes&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;){&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;echo&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot;File $i: ($file_name) Faild to upload. File must be &lt;b&gt;&quot;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;&lt;b&gt;.&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;&lt;b&gt;$size_bytes&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;&lt;b&gt;/&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;&lt;b&gt;1024&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;&lt;b&gt;.&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&lt;b&gt;&quot;&lt;/b&gt; KB. &lt;br /&gt;
&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}else{&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #ff8000;&quot;&gt;#-----------------------------------------------------------#&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;# this code check if file is Already EXISTS.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; #&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;#-----------------------------------------------------------#&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;if(&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;file_exists&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$upload_dir&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$file_name&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;)){&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;echo&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot;File $i: ($file_name) already exists.&lt;br /&gt;
&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}else{&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #ff8000;&quot;&gt;#-----------------------------------------------------------#&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;# this function will upload the files.&amp;nbsp; :) ;) cool&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; #&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;#-----------------------------------------------------------#&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;if (&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;move_uploaded_file&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$file_tmp&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$upload_dir&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$file_name&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;)) {&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;echo&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot;File $i: ($file_name) Uploaded.&lt;br /&gt;
&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}else{&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; echo&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot;File $i: Faild to upload.&lt;br /&gt;
&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;span style=&quot;color: #ff8000;&quot;&gt;#end of (move_uploaded_file).&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #ff8000;&quot;&gt;#end of (file_exists).&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #ff8000;&quot;&gt;#end of (file_size).&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #ff8000;&quot;&gt;#end of (limitedext).&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #ff8000;&quot;&gt;#end of (!is_uploaded_file).&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #ff8000;&quot;&gt;#end of (for loop).&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;# print back button.&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;echo&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot;»&lt;a href=&quot;http://www.blogger.com/%5C%22$_SERVER%5BPHP_SELF%5D%5C%22&quot;&gt;back&lt;/a&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff8000;&quot;&gt;////////////////////////////////////////////////////////////////////////////////&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
//else if the form didn&#39;t submitted then show it.&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;}else{&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; echo&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot; &lt;h3&gt;Select files to upload!.&lt;/h3&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Max file size = &quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;.&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$size_bytes&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;/&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;1024&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot; KB&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; echo&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot; &lt;form action=&quot;\&amp;quot;$_SERVER[PHP_SELF]\&amp;quot;&quot; enctype=&quot;\&amp;quot;multipart/form-data\&amp;quot;&quot; method=&quot;\&amp;quot;post\&amp;quot;&quot;&gt;&quot;&lt;/form&gt;&lt;span style=&quot;color: #007700;&quot;&gt;;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #ff8000;&quot;&gt;// show the file input field based on($num_files).&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;for (&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$i&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;=&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$i&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;=&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$num_files&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$i&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;++) {&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;echo&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot;File $i: &lt;input name=&quot;\&amp;quot;file&amp;quot;&amp;lt;/span&quot; type=&quot;\&amp;quot;file\&amp;quot;&quot; /&gt;&lt;span style=&quot;color: #007700;&quot;&gt;.&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;$i&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot;\&quot;&amp;gt;&lt;br /&gt;
&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; echo&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot; &lt;input name=&quot;\&amp;quot;MAX_FILE_SIZE\&amp;quot;&quot; type=&quot;\&amp;quot;hidden\&amp;quot;&quot; value=&quot;\&amp;quot;$size_bytes\&amp;quot;&quot; /&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;input name=&quot;\&amp;quot;upload_form\&amp;quot;&quot; now!\=&quot;&quot; type=&quot;\&amp;quot;submit\&amp;quot;&quot; value=&quot;\&amp;quot;Upload&quot; /&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
}&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: #ff8000;&quot;&gt;//print copyright ;-)&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;echo&lt;/span&gt;&lt;span style=&quot;color: #dd0000;&quot;&gt;&quot;&lt;div align=&quot;\&amp;quot;right\&amp;quot;&quot;&gt;&lt;br /&gt;
Script by: &lt;a href=&quot;http://www.blogger.com/%5C%22http://www.maaking.com%5C%22&quot;&gt;maaking.com&lt;/a&gt;&lt;/div&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000bb;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;br /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;background-color: white; height: 15px;&quot;&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://abdulzahra-alameri-php.blogspot.com/feeds/4625672959625621119/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://abdulzahra-alameri-php.blogspot.com/2011/01/how-to-upload-multiple-files-into-myslq.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3932080116325211990/posts/default/4625672959625621119'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3932080116325211990/posts/default/4625672959625621119'/><link rel='alternate' type='text/html' href='http://abdulzahra-alameri-php.blogspot.com/2011/01/how-to-upload-multiple-files-into-myslq.html' title='How to upload multiple files into mySLQ'/><author><name>Abdul Zahra Al Ameri</name><uri>http://www.blogger.com/profile/16930336258404396441</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXoqssOhhRJKC36bZ0CJtGsg5nuarPlr4IerH_0kFBkpk_YNPxkfIWFoyL0M351NtBRxXjSYguz0iD9Tw-Y_o5aTgyHDQ9hSsr8A78WZ2l8dGvLaFgi4l9UmPR5Vsmk4w/s220/drinktea-medium.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3932080116325211990.post-5129900764117752168</id><published>2010-02-07T16:27:00.000-08:00</published><updated>2010-02-07T16:27:21.549-08:00</updated><title type='text'>How to validate the upload file is excel or not in the client side</title><content type='html'>onBlur evernt use this code.&lt;br /&gt;
&lt;br /&gt;
onblur=&quot;if(this.value.lastIndexOf(\&#39;.xls\&#39;)==-1){ alert(\&#39;Please upload only .xls extension file\&#39;); return false;}&quot;&lt;br /&gt;
&lt;br /&gt;
for PDF file&lt;br /&gt;
&lt;br /&gt;
onblur=&quot;if(this.value.lastIndexOf(\&#39;.pdf\&#39;)==-1){ alert(\&#39;Please upload only .xls extension file\&#39;); return false;}&quot;</content><link rel='replies' type='application/atom+xml' href='http://abdulzahra-alameri-php.blogspot.com/feeds/5129900764117752168/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://abdulzahra-alameri-php.blogspot.com/2010/02/how-to-validate-upload-file-is-excel-or.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3932080116325211990/posts/default/5129900764117752168'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3932080116325211990/posts/default/5129900764117752168'/><link rel='alternate' type='text/html' href='http://abdulzahra-alameri-php.blogspot.com/2010/02/how-to-validate-upload-file-is-excel-or.html' title='How to validate the upload file is excel or not in the client side'/><author><name>Abdul Zahra Al Ameri</name><uri>http://www.blogger.com/profile/16930336258404396441</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXoqssOhhRJKC36bZ0CJtGsg5nuarPlr4IerH_0kFBkpk_YNPxkfIWFoyL0M351NtBRxXjSYguz0iD9Tw-Y_o5aTgyHDQ9hSsr8A78WZ2l8dGvLaFgi4l9UmPR5Vsmk4w/s220/drinktea-medium.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3932080116325211990.post-8788328345465474244</id><published>2009-12-09T12:26:00.000-08:00</published><updated>2009-12-09T12:30:57.071-08:00</updated><title type='text'>How to prevent user from changing textfield value in html without disabling the text field.</title><content type='html'>&lt;style title=&quot;owaParaStyle&quot;&gt;
P {
 MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
BODY {
 SCROLLBAR-HIGHLIGHT-COLOR: #cecfce; SCROLLBAR-ARROW-COLOR: #3f52b8; SCROLLBAR-TRACK-COLOR: #fffbff; SCROLLBAR-DARKSHADOW-COLOR: #fafafa; SCROLLBAR-BASE-COLOR: #f7f7f7
}
&lt;/style&gt;&lt;div dir=&quot;ltr&quot;&gt;&lt;span style=&quot;font-family: tahoma; font-size: x-small;&quot;&gt;How to prevent user from changing  textfield value in html without disabling the text field.&lt;/span&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot;&gt;&lt;span style=&quot;font-family: tahoma; font-size: x-small;&quot;&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;div dir=&quot;ltr&quot;&gt;&lt;span style=&quot;font-family: tahoma; font-size: x-small;&quot;&gt;to do that, I used the  onfocus=&quot;javascript:this.blur()&quot;&lt;/span&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot;&gt;&lt;span style=&quot;font-family: tahoma; font-size: x-small;&quot;&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;div dir=&quot;ltr&quot;&gt;&lt;span style=&quot;font-family: tahoma; font-size: x-small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot;&gt;&amp;lt;input type=&quot;text&quot; name=&quot;focus&quot; value=&quot;You can not change me.  try it&quot; onfocus=&quot;javascript:this.blur();&quot;&amp;nbsp;&amp;nbsp; size=&quot;100&quot;/&amp;gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot;&gt;&lt;span style=&quot;font-family: times new roman;&quot;&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;div dir=&quot;ltr&quot;&gt;&lt;span style=&quot;font-family: times new roman;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot;&gt;&lt;span style=&quot;font-family: times new roman;&quot;&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;div dir=&quot;ltr&quot;&gt;&amp;lt;input type=&quot;text&quot; name=&quot;focus&quot; value=&quot;You can not change me.  try it&quot; onfocus=&quot;javascript:this.blur();&quot;&amp;nbsp;&amp;nbsp; size=&quot;100&quot;/&amp;amp;gt&lt;/div&gt;&lt;div dir=&quot;ltr&quot;&gt;&lt;span style=&quot;font-family: times new roman;&quot;&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;div dir=&quot;ltr&quot;&gt;&amp;nbsp;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://abdulzahra-alameri-php.blogspot.com/feeds/8788328345465474244/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://abdulzahra-alameri-php.blogspot.com/2009/12/how-to-prevent-user-from-changing.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3932080116325211990/posts/default/8788328345465474244'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3932080116325211990/posts/default/8788328345465474244'/><link rel='alternate' type='text/html' href='http://abdulzahra-alameri-php.blogspot.com/2009/12/how-to-prevent-user-from-changing.html' title='How to prevent user from changing textfield value in html without disabling the text field.'/><author><name>Abdul Zahra Al Ameri</name><uri>http://www.blogger.com/profile/16930336258404396441</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXoqssOhhRJKC36bZ0CJtGsg5nuarPlr4IerH_0kFBkpk_YNPxkfIWFoyL0M351NtBRxXjSYguz0iD9Tw-Y_o5aTgyHDQ9hSsr8A78WZ2l8dGvLaFgi4l9UmPR5Vsmk4w/s220/drinktea-medium.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3932080116325211990.post-7231179897859232989</id><published>2009-11-30T15:47:00.000-08:00</published><updated>2009-11-30T15:49:40.350-08:00</updated><title type='text'>How to replace a space with an underscore in php</title><content type='html'>&lt;meta content=&quot;text/html; charset=utf-8&quot; http-equiv=&quot;Content-Type&quot;&gt;&lt;/meta&gt;&lt;meta content=&quot;Word.Document&quot; name=&quot;ProgId&quot;&gt;&lt;/meta&gt;&lt;meta content=&quot;Microsoft Word 11&quot; name=&quot;Generator&quot;&gt;&lt;/meta&gt;&lt;meta content=&quot;Microsoft Word 11&quot; name=&quot;Originator&quot;&gt;&lt;/meta&gt;&lt;link href=&quot;file:///C:%5CDOCUME%7E1%5Ctamer%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml&quot; rel=&quot;File-List&quot;&gt;&lt;/link&gt;&lt;style&gt;
&lt;!--
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:&quot;&quot;;
	margin:0cm;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:&quot;Times New Roman&quot;;
	mso-fareast-font-family:&quot;Times New Roman&quot;;}
pre
	{margin:0cm;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:&quot;Courier New&quot;;
	mso-fareast-font-family:&quot;Times New Roman&quot;;}
span.kw2
	{mso-style-name:kw2;}
span.re0
	{mso-style-name:re0;}
span.br0
	{mso-style-name:br0;}
span.kw3
	{mso-style-name:kw3;}
span.st0
	{mso-style-name:st0;}
@page Section1
	{size:612.0pt 792.0pt;
	margin:72.0pt 90.0pt 72.0pt 90.0pt;
	mso-header-margin:36.0pt;
	mso-footer-margin:36.0pt;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
--&gt;
&lt;/style&gt;  &lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;How to replace a space with an underscore in php&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;To do that, I used str_replace function in php. &lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;Example.&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;pre style=&quot;margin-left: 18pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;&lt;pre style=&quot;margin-left: 18pt;&quot;&gt;$name = $_POST[name];&lt;/pre&gt;&lt;pre style=&quot;margin-left: 18pt;&quot;&gt;$pagelink = str_replace(&quot; &quot;,&quot;_&quot;,$name);&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;&lt;pre style=&quot;margin-left: 18pt;&quot;&gt;?&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://abdulzahra-alameri-php.blogspot.com/feeds/7231179897859232989/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://abdulzahra-alameri-php.blogspot.com/2009/11/how-to-replace-space-with-underscore-in.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3932080116325211990/posts/default/7231179897859232989'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3932080116325211990/posts/default/7231179897859232989'/><link rel='alternate' type='text/html' href='http://abdulzahra-alameri-php.blogspot.com/2009/11/how-to-replace-space-with-underscore-in.html' title='How to replace a space with an underscore in php'/><author><name>Abdul Zahra Al Ameri</name><uri>http://www.blogger.com/profile/16930336258404396441</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXoqssOhhRJKC36bZ0CJtGsg5nuarPlr4IerH_0kFBkpk_YNPxkfIWFoyL0M351NtBRxXjSYguz0iD9Tw-Y_o5aTgyHDQ9hSsr8A78WZ2l8dGvLaFgi4l9UmPR5Vsmk4w/s220/drinktea-medium.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3932080116325211990.post-7494793323795562771</id><published>2009-11-26T16:49:00.001-08:00</published><updated>2009-11-26T16:49:55.116-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Uploading Files with PHP"/><title type='text'>Uploading Files with PHP</title><content type='html'>Uploading Files with PHP&lt;br /&gt;
&lt;br /&gt;
The HTML Form&lt;br /&gt;
This script will allow you to upload files from your browser to your hosting, using PHP. The first thing we need to do is create an HTML form that allows people to choose the file they want to upload.&lt;br /&gt;
&lt;br /&gt;
    &lt;form enctype=&quot;multipart/form-data&quot; action=&quot;upload.php&quot; method=&quot;POST&quot;&gt;    Please choose a file: &lt;input name=&quot;uploaded&quot; type=&quot;file&quot; /&gt;&lt;br /&gt;&lt;br /&gt;
    &lt;input type=&quot;submit&quot; value=&quot;Upload&quot; /&gt;&lt;br /&gt;
    &lt;/form&gt;&lt;br /&gt;
This form sends data to the file &quot;upload.php&quot;, which is what we will be creating next to actually upload the file. &lt;br /&gt;
&lt;br /&gt;
Uploading the File&lt;br /&gt;
&lt;br /&gt;
The actual file upload is very simple:&lt;br /&gt;
&lt;br /&gt;
    &lt;?php
    $target = &quot;upload/&quot;;
    $target = $target . basename( $_FILES[&#39;uploaded&#39;][&#39;name&#39;]) ;
    $ok=1;
    if(move_uploaded_file($_FILES[&#39;uploaded&#39;][&#39;tmp_name&#39;], $target))
    {
    echo &quot;The file &quot;. basename( $_FILES[&#39;uploadedfile&#39;][&#39;name&#39;]). &quot; has been uploaded&quot;;
    }
    else {
    echo &quot;Sorry, there was a problem uploading your file.&quot;;
    }
    ?&gt; &lt;br /&gt;
&lt;br /&gt;
This very small piece of code will upload files sent to it by your HTML form.&lt;br /&gt;
&lt;br /&gt;
   1. The first line $target = &quot;upload/&quot;; is where we assign the folder that files will be uploaded to. As you can see in the second line, this folder is relative to the upload.php file. So for example, if your file was at www.yours.com/files/upload.php then it would upload files to www.yours.com/files/upload/yourfile.gif. Be sure you remember to create this folder!&lt;br /&gt;
&lt;br /&gt;
   2. We are not using $ok=1; at the moment but we will later in the tutorial.&lt;br /&gt;
&lt;br /&gt;
   3. We then move the uploaded file to where it belongs using move_uploaded_file (). This places it in the directory we specified at the beginning of our script. If this fails the user is given an error message, otherwise they are told that the file has been uploaded.&lt;br /&gt;
  &lt;br /&gt;
  Limit the File Size&lt;br /&gt;
     if ($uploaded_size &gt; 350000)&lt;br /&gt;
    {&lt;br /&gt;
    echo &quot;Your file is too large.&lt;br&gt;&quot;;&lt;br /&gt;
    $ok=0;&lt;br /&gt;
    } &lt;br /&gt;
&lt;br /&gt;
Assuming that you didn&#39;t change the form field in our HTML form (so it is still named uploaded), this will check to see the size of the file. If the file is larger than 350k, they are given a file too large error, and we set $ok to equal 0.&lt;br /&gt;
&lt;br /&gt;
You can change this line to be a larger or smaller size if you wish by changing 350000 to a different number. Or if you don&#39;t care about file size, just leave these lines out. &lt;br /&gt;
&lt;br /&gt;
Limit Files by Type&lt;br /&gt;
&lt;br /&gt;
    if ($uploaded_type ==&quot;text/php&quot;)&lt;br /&gt;
    {&lt;br /&gt;
    echo &quot;No PHP files&lt;br&gt;&quot;;&lt;br /&gt;
    $ok=0;&lt;br /&gt;
    } &lt;br /&gt;
&lt;br /&gt;
The code above checks to be sure the user is not uploading a PHP file to your site. If they do upload a PHP file, they are given an error, and $ok is set to 0.&lt;br /&gt;
&lt;br /&gt;
    if (!($uploaded_type==&quot;image/gif&quot;)) {&lt;br /&gt;
    echo &quot;You may only upload GIF files.&lt;br&gt;&quot;;&lt;br /&gt;
    $ok=0;&lt;br /&gt;
    } &lt;br /&gt;
&lt;br /&gt;
In our second example we only allow users to upload .gif files, and all other types are given an error before setting $ok to 0. You can use these basic examples to allow or deny any specific file types. &lt;br /&gt;
&lt;br /&gt;
Putting It Together&lt;br /&gt;
&lt;br /&gt;
    &lt;?php
    $target = &quot;upload/&quot;;
    $target = $target . basename( $_FILES[&#39;uploaded&#39;][&#39;name&#39;]) ;
    $ok=1;

    //This is our size condition
    if ($uploaded_size &gt; 350000)&lt;br /&gt;
    {&lt;br /&gt;
    echo &quot;Your file is too large.&lt;br&gt;&quot;;&lt;br /&gt;
    $ok=0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //This is our limit file type condition&lt;br /&gt;
    if ($uploaded_type ==&quot;text/php&quot;)&lt;br /&gt;
    {&lt;br /&gt;
    echo &quot;No PHP files&lt;br&gt;&quot;;&lt;br /&gt;
    $ok=0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //Here we check that $ok was not set to 0 by an error&lt;br /&gt;
    if ($ok==0)&lt;br /&gt;
    {&lt;br /&gt;
    Echo &quot;Sorry your file was not uploaded&quot;;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //If everything is ok we try to upload it&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
    if(move_uploaded_file($_FILES[&#39;uploaded&#39;][&#39;tmp_name&#39;], $target))&lt;br /&gt;
    {&lt;br /&gt;
    echo &quot;The file &quot;. basename( $_FILES[&#39;uploadedfile&#39;][&#39;name&#39;]). &quot; has been uploaded&quot;;&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
    echo &quot;Sorry, there was a problem uploading your file.&quot;;&lt;br /&gt;
    }&lt;br /&gt;
    }&lt;br /&gt;
    ?&gt;</content><link rel='replies' type='application/atom+xml' href='http://abdulzahra-alameri-php.blogspot.com/feeds/7494793323795562771/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://abdulzahra-alameri-php.blogspot.com/2009/11/uploading-files-with-php.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3932080116325211990/posts/default/7494793323795562771'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3932080116325211990/posts/default/7494793323795562771'/><link rel='alternate' type='text/html' href='http://abdulzahra-alameri-php.blogspot.com/2009/11/uploading-files-with-php.html' title='Uploading Files with PHP'/><author><name>Abdul Zahra Al Ameri</name><uri>http://www.blogger.com/profile/16930336258404396441</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXoqssOhhRJKC36bZ0CJtGsg5nuarPlr4IerH_0kFBkpk_YNPxkfIWFoyL0M351NtBRxXjSYguz0iD9Tw-Y_o5aTgyHDQ9hSsr8A78WZ2l8dGvLaFgi4l9UmPR5Vsmk4w/s220/drinktea-medium.jpg'/></author><thr:total>0</thr:total></entry></feed>