<?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>FiddyP &#187; mysql</title>
	<atom:link href="http://fiddyp.co.uk/tag/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://fiddyp.co.uk</link>
	<description>The personal blog of Andy Bailey</description>
	<lastBuildDate>Sun, 13 May 2012 15:28:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>How to do a mass text search and replace with MySQL</title>
		<link>http://fiddyp.co.uk/how-to-do-a-mass-text-search-and-replace-with-mysql/</link>
		<comments>http://fiddyp.co.uk/how-to-do-a-mass-text-search-and-replace-with-mysql/#comments</comments>
		<pubDate>Sat, 24 Oct 2009 10:28:46 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[profit]]></category>
		<category><![CDATA[replace]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://fiddyp.co.uk/?p=1521</guid>
		<description><![CDATA[I noticed that all my images on the posts here weren&#8217;t showing and it was because the url to their location was still pointing at the sub blog [..]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Ffiddyp.co.uk%2Fhow-to-do-a-mass-text-search-and-replace-with-mysql%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ffiddyp.co.uk%2Fhow-to-do-a-mass-text-search-and-replace-with-mysql%2F&amp;source=commentluv&amp;style=normal&amp;service=bit.ly&amp;service_api=R_259b4e5679e2c431cca1f989e158bba4&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I noticed that all my images on the posts here weren&#8217;t showing and it was because the url to their location was still pointing at the sub blog on The Comluv Network so I needed a way to edit the database to update the url to point to the files held here.</p>
<p>Easy with a REPLACE function on the wp_posts table.</p>
<p>You just need 3 things for the replace command :
<ol>
<li>The row you&#8217;re altering</li>
<li>The string you&#8217;re searching for</li>
<li>The string you&#8217;re replacing with</li>
</ol>
<p><code>UPDATE `wp_posts` SET `post_content` = REPLACE( `post_content` , "fiddyp.comluv.com/files/", "fiddyp.co.uk/wp-content/uploads/" )</code></p>
<p>It did the whole table of posts in less than a second. Sweet, now all my images are back to normal on this site.</p>
]]></content:encoded>
			<wfw:commentRss>http://fiddyp.co.uk/how-to-do-a-mass-text-search-and-replace-with-mysql/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>My life in (other peoples) pictures</title>
		<link>http://fiddyp.co.uk/my-life-in-other-peoples-pictures/</link>
		<comments>http://fiddyp.co.uk/my-life-in-other-peoples-pictures/#comments</comments>
		<pubDate>Fri, 08 Aug 2008 12:41:32 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Blog News]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Funnies]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[commentluv]]></category>
		<category><![CDATA[idea]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[profit]]></category>

		<guid isPermaLink="false">http://www.fiddyp.co.uk/?p=431</guid>
		<description><![CDATA[ok so, last week, I was like.. but, then I was like.. which had me feeling like.. until I wanted to &#8230; but then.. so I needed to [..]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Ffiddyp.co.uk%2Fmy-life-in-other-peoples-pictures%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ffiddyp.co.uk%2Fmy-life-in-other-peoples-pictures%2F&amp;source=commentluv&amp;style=normal&amp;service=bit.ly&amp;service_api=R_259b4e5679e2c431cca1f989e158bba4&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<h3>ok so, last week, I was like..<br />
<a href="http://www.flickr.com/photos/66164549@N00/2260970300/"><img src="http://fiddyp.co.uk/wp-content/uploads/2008/08/thinkingmonkey.jpg" alt="" width="240" height="180" class="alignnone size-medium wp-image-432" /></a></p>
<p>but, then I was like..<br />
<img src="http://fiddyp.co.uk/wp-content/uploads/2008/08/stupid_genius1.jpg" alt="" width="292" height="266" class="alignnone size-medium wp-image-433" /></p>
<p>which had me feeling like..<br />
<a href="http://www.flickr.com/photos/amsterdamned/418389653/"><img src="http://fiddyp.co.uk/wp-content/uploads/2008/08/boredkid.jpg" alt="" width="167" height="240" class="alignnone size-medium wp-image-434" /></a></p>
<p>until I wanted to &#8230;<br />
<a href="http://www.flickr.com/photos/joshsommers/363202072/"><img src="http://fiddyp.co.uk/wp-content/uploads/2008/08/screaminfinite.jpg" alt="" width="240" height="197" class="alignnone size-medium wp-image-436" /></a></p>
<p>but then..<br />
<img src="http://www.fiddyp.co.uk/wp-content/uploads/2008/08/charlie-sigh-769156-231x300.jpg" alt="" width="231" height="300" class="alignnone size-medium wp-image-438" /></p>
<p>so I needed to ..<br />
<a href="http://www.flickr.com/photos/metabolico/460873307/"><img src="http://fiddyp.co.uk/wp-content/uploads/2008/08/readbigbook.jpg" alt="" width="240" height="180" class="alignnone size-medium wp-image-439" /></a></p>
<p>and &#8230;<br />
<img src="http://www.fiddyp.co.uk/wp-content/uploads/2008/08/usecomputer-300x248.jpg" alt="" width="300" height="248" class="alignnone size-medium wp-image-440" /></p>
<p>but it was hard&#8230;<br />
<a href="http://www.flickr.com/photos/joshbrown/5321381/"><img src="http://fiddyp.co.uk/wp-content/uploads/2008/08/ohthehorrorchild.jpg" alt="" width="187" height="240" class="alignnone size-medium wp-image-441" /></a></p>
<p>and inevitably&#8230;<br />
<img src="http://www.fiddyp.co.uk/wp-content/uploads/2008/08/thestupiditburns-263x300.jpg" alt="" width="263" height="300" class="alignnone size-medium wp-image-443" /></p>
<p>but at last!&#8230;<br />
<a href="http://www.flickr.com/photos/input/148075370/"><img src="http://www.fiddyp.co.uk/wp-content/uploads/2008/08/seethelight-300x225.jpg" alt="" width="300" height="225" class="alignnone size-medium wp-image-444" /></a></p>
<p>so now I&#8217;m like&#8230;<img src="http://www.fiddyp.co.uk/wp-content/uploads/2008/08/victorious-159x300.jpg" alt="" width="159" height="300" class="alignnone size-medium wp-image-446" /><br />
</h3>
<p>MYSQL &#8211; I OWN YOU!! hahahaha</p>
<p>Now I can really start to get to work on the CommentLuv site. I can pull just about any combination of data out of the database. Things like..
<ul>
<li>Last 10 links to receive CommentLuv on any site<br />
(for version 1.97 CommentLuv upwards)</li>
<li>Last 10 links from a particular URL</li>
<li>Last 10 links to a particular url</li>
<li>Top commented posts<br />
(that received CommentLuv on them)</li>
<li>Top commentators<br />
(who received CommentLuv)</li>
<li>Ban spammers!</li>
<li>Use a cacheing system for speedier retreival</li>
<li>Store default feed url&#8217;s for even speedier parsing</li>
<li>probably tons more but that&#8217;s what I&#8217;ve been playing with all this week</li>
</ul>
<p>Keep tuned for more exciting CommentLuv news</p>
]]></content:encoded>
			<wfw:commentRss>http://fiddyp.co.uk/my-life-in-other-peoples-pictures/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
		<item>
		<title>How to extract names and email addresses from your WP database</title>
		<link>http://fiddyp.co.uk/how-to-extract-names-and-email-addresses-from-your-wp-database/</link>
		<comments>http://fiddyp.co.uk/how-to-extract-names-and-email-addresses-from-your-wp-database/#comments</comments>
		<pubDate>Thu, 27 Mar 2008 23:30:06 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[comment]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[extract]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[phpmyadmin]]></category>
		<category><![CDATA[profit]]></category>

		<guid isPermaLink="false">http://www.fiddyp.co.uk/how-to-extract-names-and-email-addresses-from-your-wp-database/</guid>
		<description><![CDATA[I had to do some playing around with my wordpress database when I wanted to move my install from a shared hosting to a dedicated server (which turned [..]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Ffiddyp.co.uk%2Fhow-to-extract-names-and-email-addresses-from-your-wp-database%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ffiddyp.co.uk%2Fhow-to-extract-names-and-email-addresses-from-your-wp-database%2F&amp;source=commentluv&amp;style=normal&amp;service=bit.ly&amp;service_api=R_259b4e5679e2c431cca1f989e158bba4&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I had to do some playing around with my wordpress database when I wanted to move my install from a shared hosting to a dedicated server (which turned out to be quite easy!) and I went in a bit further to phpmyadmin to see what other things I could do.</p>
<p>With the current release of my new contest game, <a href="http://www.fiddyp.co.uk/play-aqua-game-and-win">Aqua Craft</a>, I wanted to let everyone that has visited here know about it and rather than wait for every single commenter to come back and see the post, I thought it might be easier to extract the email addresses of all commenters from the database and send them all a message. (luckily, only one person replied saying it was spam!).</p>
<p>I checked my wp_comments table and it had a few thousand entries, yey! I thought. I&#8217;ll send them all a message! I extracted the table into a csv file and was disappointed to see literally hundreds and hundreds of spammer email addresses in there&#8230;</p>
<p><a href='http://fiddyp.co.uk/wp-content/uploads/2008/03/rawphpmyadlist.jpg' title='wp_comments table with spam addresses'><img src='http://fiddyp.co.uk/wp-content/uploads/2008/03/rawphpmyadlist-150x150.jpg' alt='wp_comments table with spam addresses' /></a></p>
<p>Not being a mysql database geek, I did some searching and found a way to extract all the addresses of the commenters that had been approved&#8230; here&#8217;s how&#8230;</p>
<p>1.) Log in to phpmyadmin<br />
2.) select the wp_comments table on the left and click the &#8220;browse&#8221; button on comment_author_email</p>
<p><a href='http://fiddyp.co.uk/wp-content/uploads/2008/03/phpmyadtable.jpg' title='phpmyadmin wp_comments table'><img src='http://fiddyp.co.uk/wp-content/uploads/2008/03/phpmyadtable-150x150.jpg' alt='phpmyadmin wp_comments table' /></a></p>
<p>3.) Click &#8220;edit&#8221; on the mysql statment at the top of the page and change it to the following</p>
<p><a href='http://fiddyp.co.uk/wp-content/uploads/2008/03/selectcsv.jpg' title='edit mysql statement'><img src='http://fiddyp.co.uk/wp-content/uploads/2008/03/selectcsv-150x150.jpg' alt='edit mysql statement' /></a></p>
<p>SELECT * FROM `wp_comments` WHERE `comment_approved` = &#8217;1&#8242;</p>
<p>That will show you a list of all the comments made that have been approved.</p>
<p>4.) Click on the &#8220;export&#8221; tab and select these options..</p>
<p><a href='http://fiddyp.co.uk/wp-content/uploads/2008/03/exportcsv.jpg' title='export approved comments'><img src='http://fiddyp.co.uk/wp-content/uploads/2008/03/exportcsv-150x150.jpg' alt='export approved comments' /></a></p>
<p>This will give you a large .csv file ready to be opened by Excel</p>
<p>5.) Open the file in excel which will give you this..</p>
<p><a href='http://fiddyp.co.uk/wp-content/uploads/2008/03/rawcsv.jpg' title='raw csv file'><img src='http://fiddyp.co.uk/wp-content/uploads/2008/03/rawcsv-150x150.jpg' alt='raw csv file' /></a></p>
<p>This is a lot more than we need, so delete the columns for comment id, comment content etc so you&#8217;re left with comment_author, comment_author_email and comment_author_url</p>
<p>6.) Your excel file should look like this&#8230;</p>
<p><a href='http://fiddyp.co.uk/wp-content/uploads/2008/03/fixedcsv.jpg' title='Fixed csv file'><img src='http://fiddyp.co.uk/wp-content/uploads/2008/03/fixedcsv-150x150.jpg' alt='Fixed csv file' /></a></p>
<p>Now there will be a lot of duplicate email addresses from multiple commenters but if you have a decent newsletter or mass email program, you should be able to import this file and let it filter out all the dupes and discard the trackbacks and pings.</p>
<p>Easy peasy! I ended up with a few hundred email addresses who I could tell about my latest contest.. awesome&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://fiddyp.co.uk/how-to-extract-names-and-email-addresses-from-your-wp-database/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>

