<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Frozen Rider - Roaming</title>
	<atom:link href="http://blog.xrdavies.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://blog.xrdavies.com</link>
	<description>Roaming</description>
	<lastBuildDate>Tue, 27 Jul 2010 20:55:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>my facebook</title>
		<link>http://blog.xrdavies.com/?p=42</link>
		<comments>http://blog.xrdavies.com/?p=42#comments</comments>
		<pubDate>Tue, 27 Jul 2010 20:55:35 +0000</pubDate>
		<dc:creator>xrdavies</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.xrdavies.com/?p=42</guid>
		<description><![CDATA[Rui Xie 创建您的徽章]]></description>
			<content:encoded><![CDATA[<p><!-- Facebook Badge START --><a style="font-family: &amp;quot;lucida grande&amp;quot;,tahoma,verdana,arial,sans-serif; font-size: 11px; font-variant: normal; font-style: normal; font-weight: normal; color: #3b5998; text-decoration: none;" title="Rui Xie" href="http://zh-cn.facebook.com/people/Rui-Xie/100001435231165" target="_TOP">Rui Xie</a><br />
<a title="Rui Xie" href="http://zh-cn.facebook.com/people/Rui-Xie/100001435231165" target="_TOP"><img style="border: 0px;" src="http://badge.facebook.com/badge/100001435231165.45.1822279013.png" alt="" width="120" height="272" /></a><br />
<a style="font-family: &amp;quot;lucida grande&amp;quot;,tahoma,verdana,arial,sans-serif; font-size: 11px; font-variant: normal; font-style: normal; font-weight: normal; color: #3b5998; text-decoration: none;" title="制作你自己的电子名片" href="http://zh-cn.facebook.com/badges/" target="_TOP">创建您的徽章</a></p>
<p><!-- Facebook Badge END --></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.xrdavies.com/?feed=rss2&amp;p=42</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to solve the Adobe PDF reader error</title>
		<link>http://blog.xrdavies.com/?p=40</link>
		<comments>http://blog.xrdavies.com/?p=40#comments</comments>
		<pubDate>Tue, 20 Jul 2010 11:07:24 +0000</pubDate>
		<dc:creator>xrdavies</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[Adobe reader 9.0]]></category>
		<category><![CDATA[Invalid Plugin Detect]]></category>

		<guid isPermaLink="false">http://blog.xrdavies.com/?p=40</guid>
		<description><![CDATA[There are many plug-ins with Adobe PDF reader. And sometimes some errors related to plug-ins occur. Now, I met an error like &#8221; Invalid Plugin Detect&#8221;, and can not open any PDF file anymore. 1. cd to C:\Program Files\Adobe\Reader 9.0\Reader\plug_ins 2. choose [View]-&#62;[Choose Detail]-&#62;[check the owner option]. 3. Find the one without ownership of administrator [...]]]></description>
			<content:encoded><![CDATA[<p>There are many plug-ins with Adobe PDF reader.</p>
<p>And sometimes some errors related to plug-ins occur.</p>
<p>Now, I met an error like &#8221; Invalid Plugin Detect&#8221;, and can not open any PDF file anymore.</p>
<p>1. cd to C:\Program Files\Adobe\Reader 9.0\Reader\plug_ins</p>
<p>2. choose [View]-&gt;[Choose Detail]-&gt;[check the owner option].</p>
<p>3. Find the one without ownership of administrator and delete it.</p>
<p>Then you can use your adobe reader again.</p>
<p>Take care of all Adobe PDF reader plug-ins, many of them are not needed.</p>
<p>And now there are some critical bugs about Adobe PDF reader.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.xrdavies.com/?feed=rss2&amp;p=40</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Greenhouse girl 花房姑娘</title>
		<link>http://blog.xrdavies.com/?p=36</link>
		<comments>http://blog.xrdavies.com/?p=36#comments</comments>
		<pubDate>Mon, 05 Jul 2010 15:36:52 +0000</pubDate>
		<dc:creator>xrdavies</dc:creator>
				<category><![CDATA[My Life]]></category>
		<category><![CDATA[cuijian]]></category>
		<category><![CDATA[greenhouse girl]]></category>
		<category><![CDATA[song]]></category>
		<category><![CDATA[崔健]]></category>
		<category><![CDATA[花房姑娘]]></category>

		<guid isPermaLink="false">http://blog.xrdavies.com/?p=36</guid>
		<description><![CDATA[Alone I walk past you/ But have nothing to say
I dare not raise my head to look at your/ (oh!) Face
You ask me where I'm heading/ I point to the ocean
Your surprise seems to give me/ (oh!) Praise
(You ask me where I'm heading/ I point to the ocean)]]></description>
			<content:encoded><![CDATA[<p><strong>GREENHOUSE GIRL – Cui Jian</strong></p>
<p>Alone I walk past you/ But have nothing to say<br />
I dare not raise my head to look at your/ (oh!) Face<br />
You ask me where I&#8217;m heading/ I point to the ocean<br />
Your surprise seems to give me/ (oh!) Praise<br />
(You ask me where I&#8217;m heading/ I point to the ocean)</p>
<p>You lead me into your greenhouse/ I am intoxicated by the fragrance<br />
And without realizing it I forget my/ (oh!) Destination<br />
You say that I am the strongest in the world/ I say you are the kindest in the world<br />
And gradually the flower and I become/ (oh!) One<br />
(You say that I am the strongest in the world/ I say you are the kindest in the world)</p>
<p>You want me to stay here/ You want me to be like them<br />
I look at you and silently say that&#8217;s/ (oh!) Impossible<br />
I wish I could return to that old place/ I wish I could walk down that old road<br />
But only then do I realize I can&#8217;t leave you/ (oh!) Girl<br />
I will return to that old place/ I will walk down that old road<br />
Even though I&#8217;m sure I can&#8217;t leave you/ (oh!) Girl</p>
<p><strong>花房(huāfáng)<strong>姑娘(gūniáng)<strong> ——崔健(cuījiàn)<strong> </strong></strong></strong></strong></p>
<p>我(wǒ)独自(dúzì)走过(zǒuguò)你(nǐ)身旁(shēnpáng), 并没有(bìngméiyǒu)话(huà)要(yào)对(duì)你(nǐ)讲(jiǎng),</p>
<p>我(wǒ)不敢(bùgǎn)抬头(táitóu)看(kàn)着(zhe)你(nǐ)的(de), 噢(ō)&#8230;&#8230;脸庞(liǎnpáng).</p>
<p>你(nǐ)问(wèn)我(wǒ)要(yào)去向(qùxiàng)何(hé)方(fāng), 我(wǒ)指(zhǐ)着(zhe)大(dà)海(hǎi)的(de)方(fāng)向(xiàng),</p>
<p>你(nǐ)的(de)惊(jīng)奇(qí)像(xiàng)是(shì)给(gěi)我(wǒ), 噢(ō)&#8230;&#8230;赞(zàn)扬(yáng).</p>
<p>你(nǐ)带(dài)我(wǒ)走进(zǒujìn)你(nǐ)的(de)花房(huāfáng), 我(wǒ)无法(wúfǎ)逃脱(táotuō)花(huā)的(de)迷(mí)香(xiāng),</p>
<p>我(wǒ)不知不觉(bùzhībùjué)忘记(wàngjì)了(le), 噢(ō)&#8230;&#8230;方向(fāngxiàng),</p>
<p>你(nǐ)说(shuō)我(wǒ)世上(shìshàng)最(zuì)坚强(jiānqiáng), 我(wǒ)说(shuō)你(nǐ)世上(shìshàng)最(zuì)善良(shànliáng),</p>
<p>你(nǐ)不知不觉(bùzhībùjué)已(yǐ)和(hé)花儿(huāer), 噢(ō)&#8230;&#8230;一样(yíyàng)</p>
<p>你(nǐ)要(yào)我(wǒ)留(liú)在(zài)这地方(zhèdìfāng), 你(nǐ)要(yào)我(wǒ)和(hé)它们(tāmen)一样(yíyàng),</p>
<p>我(wǒ)看(kàn)着(zhe)你(nǐ)默默(mòmò)地(dì)说(shuō), 噢(ō)&#8230;&#8230;不能(bùnéng)这样,</p>
<p>我(wǒ)想(xiǎng)要(yào)回(huí)到(dào)老(lǎo)地(dì)方(fāng), 我(wǒ)想(xiǎng)要(yào)走(zǒu)在(zài)老(lǎo)路(lù)上(shàng),</p>
<p>我(wǒ)明(míng)知(zhī)我(wǒ)已(yǐ)离(lí)不(bu)开(kāi)你(nǐ)! 噢(ō)&#8230;&#8230;姑(gū)娘(niáng)!</p>
<p>我(wǒ)就(jiù)要(yào)回(huí)到(dào)老(lǎo)地(dì)方(fāng), 我(wǒ)就(jiù)要(yào)走(zǒu)在(zài)老(lǎo)路(lù)上(shàng),</p>
<p>我(wǒ)明(míng)知(zhī)我(wǒ)已(yǐ)离(lí)不(bu)开(kāi)你(nǐ)! 噢(ō)&#8230;&#8230;姑(gū)娘(niáng)!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.xrdavies.com/?feed=rss2&amp;p=36</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>To seize the chance!!</title>
		<link>http://blog.xrdavies.com/?p=35</link>
		<comments>http://blog.xrdavies.com/?p=35#comments</comments>
		<pubDate>Tue, 29 Jun 2010 01:58:59 +0000</pubDate>
		<dc:creator>xrdavies</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.xrdavies.com/?p=35</guid>
		<description><![CDATA[Look, if you had one shot, one opportunity To seize everything you ever wanted…One moment Would you capture it or just let it slip?]]></description>
			<content:encoded><![CDATA[<p>Look, if you had one shot, one opportunity<br />
To seize everything you ever wanted…One moment<br />
Would you capture it or just let it slip?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.xrdavies.com/?feed=rss2&amp;p=35</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pre-trip to Romania</title>
		<link>http://blog.xrdavies.com/?p=33</link>
		<comments>http://blog.xrdavies.com/?p=33#comments</comments>
		<pubDate>Fri, 25 Jun 2010 08:01:33 +0000</pubDate>
		<dc:creator>xrdavies</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.xrdavies.com/?p=33</guid>
		<description><![CDATA[Thanks to someone in our company choose me as his partner to transfer project from Romania, I get the chance to visit this beautiful East Europe country. Otherwise I may choose to leave this place to pursue my happiness somewhere else. Life is short, dreams always need a long time to realized. Hey, here, if [...]]]></description>
			<content:encoded><![CDATA[<p>Thanks to someone in our company choose me as his partner to transfer project from Romania, I get the chance to visit this beautiful East Europe country.</p>
<p>Otherwise I may choose to leave this place to pursue my happiness somewhere else.</p>
<p>Life is short, dreams always need a long time to realized.</p>
<p>Hey, here, if you get one chance one opportunity to seize everything you ever wanted, one moment, would you capture it or just let it slip?</p>
<p>Of course, me, must capture this only one opportunity to realize what I ever wanted.</p>
<p>Courage!!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.xrdavies.com/?feed=rss2&amp;p=33</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>You&#8217;ve got to find what you love</title>
		<link>http://blog.xrdavies.com/?p=32</link>
		<comments>http://blog.xrdavies.com/?p=32#comments</comments>
		<pubDate>Mon, 10 May 2010 04:52:30 +0000</pubDate>
		<dc:creator>xrdavies</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.xrdavies.com/?p=32</guid>
		<description><![CDATA[&#8216;You&#8217;ve got to find what you love,&#8217; Jobs says This is the text of the Commencement address by Steve Jobs, CEO of Apple Computer and of Pixar Animation Studios, delivered on June 12, 2005. I am honored to be with you today at your commencement from one of the finest universities in the world. I [...]]]></description>
			<content:encoded><![CDATA[<p>&#8216;You&#8217;ve got to find what you love,&#8217; Jobs says<br />
This is the text of the Commencement address by Steve Jobs, CEO of Apple Computer and of Pixar Animation Studios, delivered on June 12, 2005.</p>
<p>I am honored to be with you today at your commencement from one of the finest universities in the world. I never graduated from college. Truth be told, this is the closest I&#8217;ve ever gotten to a college graduation. Today I want to tell you three stories from my life. That&#8217;s it. No big deal. Just three stories.</p>
<p>The first story is about connecting the dots.</p>
<p>I dropped out of Reed College after the first 6 months, but then stayed around as a drop-in for another 18 months or so before I really quit. So why did I drop out?</p>
<p>It started before I was born. My biological mother was a young, unwed college graduate student, and she decided to put me up for adoption. She felt very strongly that I should be adopted by college graduates, so everything was all set for me to be adopted at birth by a lawyer and his wife. Except that when I popped out they decided at the last minute that they really wanted a girl. So my parents, who were on a waiting list, got a call in the middle of the night asking: &#8220;We have an unexpected baby boy; do you want him?&#8221; They said: &#8220;Of course.&#8221; My biological mother later found out that my mother had never graduated from college and that my father had never graduated from high school. She refused to sign the final adoption papers. She only relented a few months later when my parents promised that I would someday go to college.</p>
<p>And 17 years later I did go to college. But I naively chose a college that was almost as expensive as Stanford, and all of my working-class parents&#8217; savings were being spent on my college tuition. After six months, I couldn&#8217;t see the value in it. I had no idea what I wanted to do with my life and no idea how college was going to help me figure it out. And here I was spending all of the money my parents had saved their entire life. So I decided to drop out and trust that it would all work out OK. It was pretty scary at the time, but looking back it was one of the best decisions I ever made. The minute I dropped out I could stop taking the required classes that didn&#8217;t interest me, and begin dropping in on the ones that looked interesting.</p>
<p>It wasn&#8217;t all romantic. I didn&#8217;t have a dorm room, so I slept on the floor in friends&#8217; rooms, I returned coke bottles for the 5¢ deposits to buy food with, and I would walk the 7 miles across town every Sunday night to get one good meal a week at the Hare Krishna temple. I loved it. And much of what I stumbled into by following my curiosity and intuition turned out to be priceless later on. Let me give you one example:</p>
<p>Reed College at that time offered perhaps the best calligraphy instruction in the country. Throughout the campus every poster, every label on every drawer, was beautifully hand calligraphed. Because I had dropped out and didn&#8217;t have to take the normal classes, I decided to take a calligraphy class to learn how to do this. I learned about serif and san serif typefaces, about varying the amount of space between different letter combinations, about what makes great typography great. It was beautiful, historical, artistically subtle in a way that science can&#8217;t capture, and I found it fascinating.</p>
<p>None of this had even a hope of any practical application in my life. But ten years later, when we were designing the first Macintosh computer, it all came back to me. And we designed it all into the Mac. It was the first computer with beautiful typography. If I had never dropped in on that single course in college, the Mac would have never had multiple typefaces or proportionally spaced fonts. And since Windows just copied the Mac, its likely that no personal computer would have them. If I had never dropped out, I would have never dropped in on this calligraphy class, and personal computers might not have the wonderful typography that they do. Of course it was impossible to connect the dots looking forward when I was in college. But it was very, very clear looking backwards ten years later.</p>
<p>Again, you can&#8217;t connect the dots looking forward; you can only connect them looking backwards. So you have to trust that the dots will somehow connect in your future. You have to trust in something — your gut, destiny, life, karma, whatever. This approach has never let me down, and it has made all the difference in my life.</p>
<p>My second story is about love and loss.</p>
<p>I was lucky — I found what I loved to do early in life. Woz and I started Apple in my parents garage when I was 20. We worked hard, and in 10 years Apple had grown from just the two of us in a garage into a $2 billion company with over 4000 employees. We had just released our finest creation — the Macintosh — a year earlier, and I had just turned 30. And then I got fired. How can you get fired from a company you started? Well, as Apple grew we hired someone who I thought was very talented to run the company with me, and for the first year or so things went well. But then our visions of the future began to diverge and eventually we had a falling out. When we did, our Board of Directors sided with him. So at 30 I was out. And very publicly out. What had been the focus of my entire adult life was gone, and it was devastating.</p>
<p>I really didn&#8217;t know what to do for a few months. I felt that I had let the previous generation of entrepreneurs down &#8211; that I had dropped the baton as it was being passed to me. I met with David Packard and Bob Noyce and tried to apologize for screwing up so badly. I was a very public failure, and I even thought about running away from the valley. But something slowly began to dawn on me — I still loved what I did. The turn of events at Apple had not changed that one bit. I had been rejected, but I was still in love. And so I decided to start over.</p>
<p>I didn&#8217;t see it then, but it turned out that getting fired from Apple was the best thing that could have ever happened to me. The heaviness of being successful was replaced by the lightness of being a beginner again, less sure about everything. It freed me to enter one of the most creative periods of my life.</p>
<p>During the next five years, I started a company named NeXT, another company named Pixar, and fell in love with an amazing woman who would become my wife. Pixar went on to create the worlds first computer animated feature film, Toy Story, and is now the most successful animation studio in the world. In a remarkable turn of events, Apple bought NeXT, I returned to Apple, and the technology we developed at NeXT is at the heart of Apple&#8217;s current renaissance. And Laurene and I have a wonderful family together.</p>
<p>I&#8217;m pretty sure none of this would have happened if I hadn&#8217;t been fired from Apple. It was awful tasting medicine, but I guess the patient needed it. Sometimes life hits you in the head with a brick. Don&#8217;t lose faith. I&#8217;m convinced that the only thing that kept me going was that I loved what I did. You&#8217;ve got to find what you love. And that is as true for your work as it is for your lovers. Your work is going to fill a large part of your life, and the only way to be truly satisfied is to do what you believe is great work. And the only way to do great work is to love what you do. If you haven&#8217;t found it yet, keep looking. Don&#8217;t settle. As with all matters of the heart, you&#8217;ll know when you find it. And, like any great relationship, it just gets better and better as the years roll on. So keep looking until you find it. Don&#8217;t settle.</p>
<p>My third story is about death.</p>
<p>When I was 17, I read a quote that went something like: &#8220;If you live each day as if it was your last, someday you&#8217;ll most certainly be right.&#8221; It made an impression on me, and since then, for the past 33 years, I have looked in the mirror every morning and asked myself: &#8220;If today were the last day of my life, would I want to do what I am about to do today?&#8221; And whenever the answer has been &#8220;No&#8221; for too many days in a row, I know I need to change something.</p>
<p>Remembering that I&#8217;ll be dead soon is the most important tool I&#8217;ve ever encountered to help me make the big choices in life. Because almost everything — all external expectations, all pride, all fear of embarrassment or failure &#8211; these things just fall away in the face of death, leaving only what is truly important. Remembering that you are going to die is the best way I know to avoid the trap of thinking you have something to lose. You are already naked. There is no reason not to follow your heart.</p>
<p>About a year ago I was diagnosed with cancer. I had a scan at 7:30 in the morning, and it clearly showed a tumor on my pancreas. I didn&#8217;t even know what a pancreas was. The doctors told me this was almost certainly a type of cancer that is incurable, and that I should expect to live no longer than three to six months. My doctor advised me to go home and get my affairs in order, which is doctor&#8217;s code for prepare to die. It means to try to tell your kids everything you thought you&#8217;d have the next 10 years to tell them in just a few months. It means to make sure everything is buttoned up so that it will be as easy as possible for your family. It means to say your goodbyes.</p>
<p>I lived with that diagnosis all day. Later that evening I had a biopsy, where they stuck an endoscope down my throat, through my stomach and into my intestines, put a needle into my pancreas and got a few cells from the tumor. I was sedated, but my wife, who was there, told me that when they viewed the cells under a microscope the doctors started crying because it turned out to be a very rare form of pancreatic cancer that is curable with surgery. I had the surgery and I&#8217;m fine now.</p>
<p>This was the closest I&#8217;ve been to facing death, and I hope its the closest I get for a few more decades. Having lived through it, I can now say this to you with a bit more certainty than when death was a useful but purely intellectual concept:</p>
<p>No one wants to die. Even people who want to go to heaven don&#8217;t want to die to get there. And yet death is the destination we all share. No one has ever escaped it. And that is as it should be, because Death is very likely the single best invention of Life. It is Life&#8217;s change agent. It clears out the old to make way for the new. Right now the new is you, but someday not too long from now, you will gradually become the old and be cleared away. Sorry to be so dramatic, but it is quite true.</p>
<p>Your time is limited, so don&#8217;t waste it living someone else&#8217;s life. Don&#8217;t be trapped by dogma — which is living with the results of other people&#8217;s thinking. Don&#8217;t let the noise of others&#8217; opinions drown out your own inner voice. And most important, have the courage to follow your heart and intuition. They somehow already know what you truly want to become. Everything else is secondary.</p>
<p>When I was young, there was an amazing publication called The Whole Earth Catalog, which was one of the bibles of my generation. It was created by a fellow named Stewart Brand not far from here in Menlo Park, and he brought it to life with his poetic touch. This was in the late 1960&#8242;s, before personal computers and desktop publishing, so it was all made with typewriters, scissors, and polaroid cameras. It was sort of like Google in paperback form, 35 years before Google came along: it was idealistic, and overflowing with neat tools and great notions.</p>
<p>Stewart and his team put out several issues of The Whole Earth Catalog, and then when it had run its course, they put out a final issue. It was the mid-1970s, and I was your age. On the back cover of their final issue was a photograph of an early morning country road, the kind you might find yourself hitchhiking on if you were so adventurous. Beneath it were the words: &#8220;Stay Hungry. Stay Foolish.&#8221; It was their farewell message as they signed off. Stay Hungry. Stay Foolish. And I have always wished that for myself. And now, as you graduate to begin anew, I wish that for you.</p>
<p>Stay Hungry. Stay Foolish.</p>
<p>Thank you all very much.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.xrdavies.com/?feed=rss2&amp;p=32</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Import a list of CSV files into DB</title>
		<link>http://blog.xrdavies.com/?p=29</link>
		<comments>http://blog.xrdavies.com/?p=29#comments</comments>
		<pubDate>Fri, 23 Apr 2010 07:27:26 +0000</pubDate>
		<dc:creator>xrdavies</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.xrdavies.com/?p=29</guid>
		<description><![CDATA[Searched these code from Google. Import a list of CSV files into their appropriate tables and email the results when finished. By : Keegan &#60;?php # Author: Keegan # Email: keegan@sifizm.com # Web Site: www.sifizm.com # I run this script from a cron job every night to update # the mysql database I use with [...]]]></description>
			<content:encoded><![CDATA[<p>Searched these code from Google.</p>
<p>Import a list of CSV files into their appropriate tables and email the results when finished.</p>
<p>By : Keegan</p>
<p>&lt;?php<br />
# Author: Keegan<br />
# Email: keegan@sifizm.com<br />
# Web Site: www.sifizm.com</p>
<p># I run this script from a cron job every night to update<br />
# the mysql database I use with my employee web site<br />
# so it matches my local database every day. Feel free to<br />
# modify it to meet your specific needs. If you find it<br />
# usefull, drop me an email and let me know.</p>
<p># edit the follow six items to use the script</p>
<p># first connect to your mysql database<br />
# i have my connection settings in a diferent file<br />
# so i just include that file in all my scripts<br />
include(&#8220;db.php&#8221;);</p>
<p># assign the tables that you want to import to to the table array<br />
$table = array(<br />
&#8216;table1&#8242;,<br />
&#8216;table2&#8242;,<br />
&#8216;table3&#8242;,<br />
&#8216;table4&#8242;,<br />
&#8216;table5&#8242;,<br />
);</p>
<p># if the first row of your csv file contains column headings:<br />
# $columnheadings=1<br />
# if the first row does not contain column headings and should be imported:<br />
# $columnheadings=0<br />
$columnheadings = 0;</p>
<p># contains the email address you want the results sent to<br />
$emailaddress = &#8220;user@domain.com&#8221;;</p>
<p># contains the subject you want the message to have<br />
$subject = &#8220;Enter Subject Here&#8221;;</p>
<p># contains the email address that will show in the from line<br />
$emailfrom = &#8220;user@domain.com&#8221;;</p>
<p># you should not have to edit anything below this line</p>
<p># perform the required operations for every table listed in the table array<br />
foreach ($table as $tablename) {</p>
<p># empty the table of its current records<br />
$deleterecords = &#8220;TRUNCATE TABLE `$tablename`&#8221;;<br />
mysql_query($deleterecords);</p>
<p># intialize your counters for successful and failed record imports<br />
$pass = 0;<br />
$fail = 0;</p>
<p># the csv file needs to be the same name as the table,<br />
# comma seperated with the columns in the same order as the table,<br />
# and in the same dir as this script<br />
$filecontents = file (&#8220;$tablename.csv&#8221;); # .csv is added to the table name to get the name of the csv file</p>
<p># every record in the csv file will be inserted into the table unless an error occurs with that record<br />
for($i=$columnheadings; $i&lt;sizeof($filecontents); $i++) {<br />
$insertrecord = &#8220;Insert Into `$tablename` Values ($filecontents[$i])&#8221;;<br />
mysql_query($insertrecord);<br />
if(mysql_error()) {<br />
$fail += 1; # increments if there was an error importing the record<br />
}<br />
else<br />
{<br />
$pass += 1; # increments if the record was successfully imported<br />
}<br />
}</p>
<p># adds a line to the email message we will send stating how many records were imported<br />
# and how many records failed for each table<br />
$message .= &#8220;Table $tablename: Success=$pass Failure=$fail \n&#8221;;<br />
}</p>
<p># set to the date and time the script was run<br />
$runtime = (date(&#8220;d M Y H:i&#8221;));</p>
<p># add the run time to the body of the email message<br />
$message .= &#8220;\nTime of the message: $runtime (server time zone)\n\n&#8221;;</p>
<p># Send the email message<br />
mail($emailaddress, $subject, $message, &#8220;From: &#8216;$emailfrom&#8217;&#8221;);</p>
<p>?&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.xrdavies.com/?feed=rss2&amp;p=29</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Schedule PHP</title>
		<link>http://blog.xrdavies.com/?p=25</link>
		<comments>http://blog.xrdavies.com/?p=25#comments</comments>
		<pubDate>Fri, 23 Apr 2010 06:23:59 +0000</pubDate>
		<dc:creator>xrdavies</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.xrdavies.com/?p=25</guid>
		<description><![CDATA[Schedule PHP]]></description>
			<content:encoded><![CDATA[<p>看来的ＰＨＰ定时执行代码段～</p>
<p>想法挺不错的，但是服务器受得了否．</p>
<p>回头测试一下．</p>
<p>&lt;?php<br />
ignore_user_abort();           // 即使Client断开(如关掉浏览器)，PHP脚本也可以继续执行.<br />
set_time_limit(0);             // 执行时间为无限制，php默认的执行时间是30秒，通过set_time_limit(0)可以让程序无限制的执行下去<br />
$interval=20;               // 时间间隔 单位 秒<br />
$key_file=&#8221;key.txt&#8221;;          // 配置文件</p>
<p>if (isset($_GET['s']))<br />
{<br />
if ($_GET['s']==&#8221;0&#8243;){        // 停止工作，但不退出<br />
$s=&#8221;false&#8221;;<br />
echo &#8220;Function is off&#8221;;<br />
}<br />
elseif ($_GET['s']==&#8221;1&#8243;){      // 工作<br />
$s=&#8221;true&#8221;;<br />
echo &#8220;Function is on&#8221;;<br />
}<br />
elseif ($_GET['s']==&#8221;2&#8243;){      // 退出<br />
$s=&#8221;die&#8221;;<br />
echo &#8220;Function exited&#8221;;<br />
}<br />
else<br />
die(&#8220;Err 0:stop working 1:working 2:exit&#8221;);</p>
<p>$string = &#8220;&lt;?php\n return \&#8221;".$s.&#8221;\&#8221;;\n?&gt;&#8221;;<br />
write_inc($key_file,$string,true);<br />
exit();<br />
}</p>
<p>if(file_exists($key_file)){<br />
do{<br />
$mkey = include $key_file;<br />
if ($mkey==&#8221;true&#8221;){          // 如果工作<br />
/////////////////////  工作区间  //////////////////////////////////<br />
$showtime=date(&#8220;Y-m-d H:i:s&#8221;);<br />
$fp = fopen(&#8216;func.txt&#8217;,'a&#8217;);<br />
fwrite($fp,$showtime.&#8221;\n&#8221;);<br />
fclose($fp);<br />
///////////////////////////////////////////////////////////////////<br />
}<br />
elseif ($mkey==&#8221;die&#8221;){        // 如果退出<br />
die(&#8220;I am dying!&#8221;);<br />
}<br />
sleep($interval);           // 等待$interval分钟<br />
}while(true);<br />
}<br />
else<br />
die($key_file.&#8221; doesn&#8217;t exist !&#8221;);</p>
<p>function write_inc($path,$strings,$type=false)<br />
{<br />
$path=dirname(__FILE__).&#8221;/&#8221;.$path;<br />
if ($type==false)<br />
file_put_contents($path,$strings,FILE_APPEND);<br />
else<br />
file_put_contents($path,$strings);<br />
}</p>
<p>?&gt;</p>
<p>source http://blbear.com/post/187</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.xrdavies.com/?feed=rss2&amp;p=25</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title></title>
		<link>http://blog.xrdavies.com/?p=24</link>
		<comments>http://blog.xrdavies.com/?p=24#comments</comments>
		<pubDate>Thu, 22 Apr 2010 03:44:32 +0000</pubDate>
		<dc:creator>xrdavies</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.xrdavies.com/?p=24</guid>
		<description><![CDATA[&#8220;The best-informed man is not necessarily the wisest. Indeed there is a danger that precisely in the multiplicity of his knowledge he will lose sight of what is essential.&#8221; - Dietrich Bonhoeffer]]></description>
			<content:encoded><![CDATA[<p>&#8220;The best-informed man is not necessarily the wisest. Indeed there is a danger that precisely in the multiplicity of his knowledge he will lose sight of what is essential.&#8221;</p>
<p>- Dietrich Bonhoeffer</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.xrdavies.com/?feed=rss2&amp;p=24</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Programmer&#8217;s life</title>
		<link>http://blog.xrdavies.com/?p=21</link>
		<comments>http://blog.xrdavies.com/?p=21#comments</comments>
		<pubDate>Sun, 11 Apr 2010 05:28:07 +0000</pubDate>
		<dc:creator>xrdavies</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.xrdavies.com/?p=21</guid>
		<description><![CDATA[&#60;a href=&#8221;http://blog.xrdavies.com/wp-content/uploads/2010/04/p_large_7PWG_7303000071972d12.gif&#8221; title=&#8221;p_large_7PWG_7303000071972d12.gif&#8221; onclick=&#8221;return hs.expand(this)&#8221; target=&#8221;_blank&#8221;&#62;&#60;img src=&#8221;http://blog.xrdavies.com/wp-content/uploads/2010/04/p_large_7PWG_7303000071972d12.gif&#8221; alt=&#8221;p_large_7PWG_7303000071972d12.gif&#8221; width=&#8221;160&#8243; height=&#8221;160&#8243; /&#62;&#60;/a&#62;&#60;a href=&#8221;http://blog.xrdavies.com/wp-content/uploads/2010/04/p_large_bnRx_1fd800010c522d0e.gif&#8221; title=&#8221;p_large_bnRx_1fd800010c522d0e.gif&#8221; onclick=&#8221;return hs.expand(this)&#8221; target=&#8221;_blank&#8221;&#62;&#60;img src=&#8221;http://blog.xrdavies.com/wp-content/uploads/2010/04/p_large_bnRx_1fd800010c522d0e.gif&#8221; alt=&#8221;p_large_bnRx_1fd800010c522d0e.gif&#8221; width=&#8221;160&#8243; height=&#8221;160&#8243; /&#62;&#60;/a&#62;&#60;a href=&#8221;http://blog.xrdavies.com/wp-content/uploads/2010/04/p_large_CDl4_143300006f8c2d13.gif&#8221; title=&#8221;p_large_CDl4_143300006f8c2d13.gif&#8221; onclick=&#8221;return hs.expand(this)&#8221; target=&#8221;_blank&#8221;&#62;&#60;img src=&#8221;http://blog.xrdavies.com/wp-content/uploads/2010/04/p_large_CDl4_143300006f8c2d13.gif&#8221; alt=&#8221;p_large_CDl4_143300006f8c2d13.gif&#8221; width=&#8221;160&#8243; height=&#8221;160&#8243; /&#62;&#60;/a&#62;]]></description>
			<content:encoded><![CDATA[<p>&lt;a href=&#8221;http://blog.xrdavies.com/wp-content/uploads/2010/04/p_large_7PWG_7303000071972d12.gif&#8221; title=&#8221;p_large_7PWG_7303000071972d12.gif&#8221; onclick=&#8221;return hs.expand(this)&#8221; target=&#8221;_blank&#8221;&gt;&lt;img src=&#8221;http://blog.xrdavies.com/wp-content/uploads/2010/04/p_large_7PWG_7303000071972d12.gif&#8221; alt=&#8221;p_large_7PWG_7303000071972d12.gif&#8221; width=&#8221;160&#8243; height=&#8221;160&#8243; /&gt;&lt;/a&gt;&lt;a href=&#8221;http://blog.xrdavies.com/wp-content/uploads/2010/04/p_large_bnRx_1fd800010c522d0e.gif&#8221; title=&#8221;p_large_bnRx_1fd800010c522d0e.gif&#8221; onclick=&#8221;return hs.expand(this)&#8221; target=&#8221;_blank&#8221;&gt;&lt;img src=&#8221;http://blog.xrdavies.com/wp-content/uploads/2010/04/p_large_bnRx_1fd800010c522d0e.gif&#8221; alt=&#8221;p_large_bnRx_1fd800010c522d0e.gif&#8221; width=&#8221;160&#8243; height=&#8221;160&#8243; /&gt;&lt;/a&gt;&lt;a href=&#8221;http://blog.xrdavies.com/wp-content/uploads/2010/04/p_large_CDl4_143300006f8c2d13.gif&#8221; title=&#8221;p_large_CDl4_143300006f8c2d13.gif&#8221; onclick=&#8221;return hs.expand(this)&#8221; target=&#8221;_blank&#8221;&gt;&lt;img src=&#8221;http://blog.xrdavies.com/wp-content/uploads/2010/04/p_large_CDl4_143300006f8c2d13.gif&#8221; alt=&#8221;p_large_CDl4_143300006f8c2d13.gif&#8221; width=&#8221;160&#8243; height=&#8221;160&#8243; /&gt;&lt;/a&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.xrdavies.com/?feed=rss2&amp;p=21</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	<img style='margin:0;padding:0;border:0;' width='1px' height='1px' src="http://blog.xrdavies.com/wp-content/plugins/mystat/mystat.php?act=time_load&id=7506&rnd=1821256792" /></channel>
</rss>
