<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.2.3" -->
<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/"
	>

<channel>
	<title>PHP-Scripts Blog &#187; MySQL</title>
	<link>http://www.php-scripts.com</link>
	<description>Writing about PHP scripting since 12/99. Learn something new every day.</description>
	<pubDate>Thu, 09 Oct 2008 14:17:07 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.3</generator>
	<language>en</language>
			<item>
		<title>How to use MySQL REPLACE function</title>
		<link>http://www.php-scripts.com/20070314/101/</link>
		<comments>http://www.php-scripts.com/20070314/101/#comments</comments>
		<pubDate>Wed, 14 Mar 2007 17:02:43 +0000</pubDate>
		<dc:creator>TDavid</dc:creator>
		
		<category><![CDATA[How To]]></category>

		<category><![CDATA[MySQL]]></category>

		<category><![CDATA[Functions]]></category>

		<guid isPermaLink="false">http://www.php-scripts.com/20070314/101/</guid>
		<description><![CDATA[Here&#8217;s a MySQL query fuction that&#8217;s easy to forget about: REPLACE. Let&#8217;s say I have a bunch of records in a field with http://www and want to quickly change all to http://. Here&#8217;s the syntax to update:

UPDATE tdurl_1 SET URL = REPLACE(URL, &#8216;http://www.tdurl.com/&#8217;,'http://tdurl.com/&#8217;);

]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a MySQL query fuction that&#8217;s easy to forget about: REPLACE. Let&#8217;s say I have a bunch of records in a field with http://www and want to quickly change all to http://. Here&#8217;s the syntax to update:</p>
<div class="codesnip-container" >
<div class="codesnip">UPDATE tdurl_1 SET URL = REPLACE(URL, &#8216;http://www.tdurl.com/&#8217;,'http://tdurl.com/&#8217;);</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.php-scripts.com/20070314/101/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Open source phpMyEdit</title>
		<link>http://www.php-scripts.com/20061112/95/</link>
		<comments>http://www.php-scripts.com/20061112/95/#comments</comments>
		<pubDate>Sun, 12 Nov 2006 14:08:29 +0000</pubDate>
		<dc:creator>TDavid</dc:creator>
		
		<category><![CDATA[MySQL]]></category>

		<category><![CDATA[PHP 4.x]]></category>

		<guid isPermaLink="false">http://www.php-scripts.com/20061112/95/</guid>
		<description><![CDATA[phpMyEdit:
generates PHP code for displaying/editing MySQL tables in HTML. All you need to do is to write a simple calling program (a utility to do this is included). It includes a huge set of table manipulation functions (record addition, change, view, copy, and removal), table sorting, filtering, table lookups, and more.
Download (gz).
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.phpmyedit.org/">phpMyEdit</a>:<br />
<blockquote>generates PHP code for displaying/editing MySQL tables in HTML. All you need to do is to write a simple calling program (a utility to do this is included). It includes a huge set of table manipulation functions (record addition, change, view, copy, and removal), table sorting, filtering, table lookups, and more.</p></blockquote>
<p><a href="http://www.phpmyedit.org/article.php?download">Download</a> (gz).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.php-scripts.com/20061112/95/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Setting up a new Wordpress blog</title>
		<link>http://www.php-scripts.com/20051102/56/</link>
		<comments>http://www.php-scripts.com/20051102/56/#comments</comments>
		<pubDate>Wed, 02 Nov 2005 17:52:29 +0000</pubDate>
		<dc:creator>TDavid</dc:creator>
		
		<category><![CDATA[Wordpress]]></category>

		<category><![CDATA[Installation and configuration]]></category>

		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.php-scripts.com/?p=56</guid>
		<description><![CDATA[This guide assumes you have already downloaded and unzipped/untarred the most current Wordpress version. These instructions do not cover the multi-user WP version.
Steps for setting up a new Wordpress (WP) blog:
1. Database created? Create a MySQL database for the domain.
Note: If you have more than one WP blog installed in the same database then open [...]]]></description>
			<content:encoded><![CDATA[<p>This guide assumes you have already downloaded and unzipped/untarred the most current <a href="http://wordpress.org/download/">Wordpress version</a>. These instructions do <i>not</i> cover the <a href="http://mu.wordpress.org/">multi-user WP version</a>.</p>
<p>Steps for setting up a new Wordpress (WP) blog:</p>
<p>1. Database created? Create a MySQL database for the domain.</p>
<p>Note: If you have more than one WP blog installed in the same database then open up wp-config.php and change the &#8216;wp_&#8217; to something else like &#8216;wp2_&#8217; so that you can run multiple wordpress blogs in the same database.</p>
<p>2. Edit wp-config.php with the database information. Create a subdirectory in the WP version locally so you can backup the wp-config locally there.<br />
3. FTP all WP files to the target domain, including the customized wp-config.php file in step #2.<br />
4. Run the install file from your browser. Default install location is:</p>
<p>domain.com/wp-admin/install.php</p>
<p>5. Record the admin username and password somewhere safe.<br />
6. Delete the install files: install.php, install-helper.php<br />
7. Create a primary user: Users -> Authors &#038; Users -> Add New User<br />
8. Promote this user to Level 9 (which is one level beneath the Admin level of 10).<br />
9. Add whatever plugins you want to use. Here&#8217;s some you might try:</p>
<p><a href="http://www.ioerror.us/software/bad-behavior/">bad behavior</a> - shut down the spambots<br />
<a href="http://blog.enargi.com/codesnippet/">codesnippet</a> - allows you to include code snippets inside posts<br />
<a href="http://cjbehm.dyndns.org/wingingit/dashboard-options/">dashboard options</a> - add PHP code snippets, RSS feeds and more to your dashboard<br />
<a href="http://blog.taragana.com/index.php/archive/wordpress-15-plugin-strip-nofollow-tag-from-comment-urls/">follow</a> - removes the rel=nofollow links from comments<br />
<a href="http://mnm.uib.es/gallir/wp-cache-2/">wp-cache 2.0</a> - cache pages to speed up loading<br />
page navigation - adds page spanning 1,2,3&#8230; to WP pages<br />
<a href="http://somethingunpredictable.com/wp-dash/">WP-Dash</a> - replace the default admin area</p>
<p>10. Clean up the default Links area, adding/removing any default links.<br />
11. Delete the test post and make a first test placeholder post. Something like &#8220;Hello World&#8221; but by this new user.<br />
12. Choose a template or design your own. Starting with the default template might be helpful. There are detailed instructions at the WP codex for how to make custom WP templates.<br />
13. Start posting!</p>
<p>This post will be updated over time as I&#8217;m using this for my own reference too, so might want to bookmark this one.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.php-scripts.com/20051102/56/feed/</wfw:commentRss>
		</item>
		<item>
		<title>MySQL 5.0 production version now available, includes subqueries</title>
		<link>http://www.php-scripts.com/20051024/52/</link>
		<comments>http://www.php-scripts.com/20051024/52/#comments</comments>
		<pubDate>Tue, 25 Oct 2005 02:46:58 +0000</pubDate>
		<dc:creator>TDavid</dc:creator>
		
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.php-scripts.com/?p=52</guid>
		<description><![CDATA[MySQL 5.0 is now ready for use on production servers touting the following features: stored procedures and SQL functions, triggers, views, cursors, information schema, XA distributed transactions, SQL mode, new federated and archive storage engines, new migration toolkit, instance manager, updated connectors, visual tools and more.
Complete list of changes in 5.0.x production.
The functionality I&#8217;m excited [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.mysql.com/news-and-events/news/article_976.html">MySQL 5.0</a> is now ready for use on production servers touting the following features: stored procedures and SQL functions, triggers, views, cursors, information schema, XA distributed transactions, SQL mode, new federated and archive storage engines, new migration toolkit, instance manager, updated connectors, visual tools and more.</p>
<p>Complete list of <a href="http://dev.mysql.com/doc/refman/5.0/en/news-5-0-x.html">changes in 5.0.x production</a>.</p>
<p>The functionality I&#8217;m excited about is <a href="http://dev.mysql.com/doc/refman/5.0/en/subqueries.html">subqueries</a>: &#8220;MySQL 5.0 supports all subquery forms and operations that the SQL standard requires, as well as a few features that are MySQL-specific.&#8221;</p>
<p>I&#8217;m going to install this on a machine and start checking it out.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.php-scripts.com/20051024/52/feed/</wfw:commentRss>
		</item>
		<item>
		<title>ARSC v3.0.2 RC 2 free chat</title>
		<link>http://www.php-scripts.com/20051010/34/</link>
		<comments>http://www.php-scripts.com/20051010/34/#comments</comments>
		<pubDate>Mon, 10 Oct 2005 15:39:34 +0000</pubDate>
		<dc:creator>TDavid</dc:creator>
		
		<category><![CDATA[MySQL]]></category>

		<category><![CDATA[Free Scripts]]></category>

		<guid isPermaLink="false">http://www.php-scripts.com/?p=34</guid>
		<description><![CDATA[Looking to add chat to your server? Don&#8217;t want to mess with java and IRC? Want to try a PHP/MySQL solution? ARSC could be for you. 

From the 4-step installation from INSTALL docs:
- Create a MySQL database
- Provide the hostname, username, password, and database
  name to allow ARSC to connect to your MySQL Server
- [...]]]></description>
			<content:encoded><![CDATA[<p>Looking to add chat to your server? Don&#8217;t want to mess with java and IRC? Want to try a PHP/MySQL solution? <a href="http://manuel.kiessling.net/projects/software/arsc/#what">ARSC</a> could be for you. </p>
<p><img src="http://www.php-scripts.com/images/2005/arsc-1.jpg" border="0" ALT="ARSC free PHP / MySQL chat"/></p>
<p>From the 4-step installation from <a href="http://manuel.kiessling.net/projects/software/arsc/INSTALL">INSTALL docs</a>:<br />
<blockquote>- Create a MySQL database<br />
- Provide the hostname, username, password, and database<br />
  name to allow ARSC to connect to your MySQL Server<br />
- Copy the ARSC files onto the webserver<br />
- Open the install script url in the webbrowser
</p></blockquote>
<p>We have been looking to do some kind of chat for <a href="http://www.webmastercookbook.com/">Webmaster Cookbook</a>, so I just conducted a quick installation there to see how long the base installation actually took.</p>
<p>Started 8:02am. End: 8:15am. 13 minutes which included creating the database  and user/pass in PHPMyAdmin and FTPing the files.</p>
<p><b>Notes</b><br />
- don&#8217;t forget to delete the install subdirectory<br />
- customize the outside and inside pages using the layout option in the admin area</p>
]]></content:encoded>
			<wfw:commentRss>http://www.php-scripts.com/20051010/34/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Query results within last X days</title>
		<link>http://www.php-scripts.com/20051005/31/</link>
		<comments>http://www.php-scripts.com/20051005/31/#comments</comments>
		<pubDate>Wed, 05 Oct 2005 14:10:05 +0000</pubDate>
		<dc:creator>TDavid</dc:creator>
		
		<category><![CDATA[MySQL]]></category>

		<category><![CDATA[PHP 4.x]]></category>

		<category><![CDATA[Information]]></category>

		<guid isPermaLink="false">http://www.php-scripts.com/?p=31</guid>
		<description><![CDATA[Sometimes it is necessary to query data from the last 7 days. Here&#8217;s how to create a dynamic query inside a script using PHP / MySQL to return a list of users who last visited within X number of days (7 by default):

&#60;?php
$now = time&#40;&#41;; // this is the current UNIX timestamp for the server
$days [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes it is necessary to query data from the last 7 days. Here&#8217;s how to create a dynamic query inside a script using PHP / MySQL to return a list of users who last visited within X number of days (7 by default):</p>
<div class="codesnip-container" >
<div class="codesnip">&lt;?php<br />
<span class="re0">$now</span> = <a href="http://www.php.net/time"><span class="kw3">time</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span>; <span class="co1">// this is the current UNIX timestamp for the server</span><br />
<span class="re0">$days</span> = <span class="nu0">7</span>; <span class="co1">// change to number of days</span><br />
<span class="re0">$days_ago</span> = <a href="http://www.php.net/date"><span class="kw3">date</span></a><span class="br0">&#40;</span><span class="st0">&#8220;Y-m-d H:i:s&#8221;</span>, <span class="br0">&#40;</span><span class="re0">$now</span> - <span class="br0">&#40;</span><span class="nu0">86400</span> * <span class="re0">$days</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp;<span class="re0">$query</span> = <span class="st0">&#8220;SELECT username FROM users WHERE lastvisited &gt; &#8216;$days_ago&#8217;&#8221;</span>;<br />
&nbsp;<span class="re0">$result</span> = @<a href="http://www.php.net/mysql_query"><span class="kw3">mysql_query</span></a><span class="br0">&#40;</span><span class="re0">$query</span>,<span class="re0">$mysql_link</span><span class="br0">&#41;</span>;<br />
&nbsp;<span class="kw1">if</span><span class="br0">&#40;</span>@<a href="http://www.php.net/mysql_num_rows"><span class="kw3">mysql_num_rows</span></a><span class="br0">&#40;</span><span class="re0">$result</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">while</span><span class="br0">&#40;</span><span class="re0">$row</span> = <a href="http://www.php.net/mysql_fetch_row"><span class="kw3">mysql_fetch_row</span></a><span class="br0">&#40;</span><span class="re0">$result</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://www.php.net/print"><span class="kw3">print</span></a> <span class="st0">&#8220;$row[0] &lt;br /&gt;&#8221;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span><br />
&nbsp;<span class="br0">&#125;</span><br />
<span class="kw2">?&gt;</span></div>
</div>
<p>Notes:<br />
- $mysql_link contains the MySQL database connection link.<br />
- 86400 is the number of seconds in a day: 60 seconds x 60 minutes x 24 hours = 86,400</p>
]]></content:encoded>
			<wfw:commentRss>http://www.php-scripts.com/20051005/31/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Changing databases inside code</title>
		<link>http://www.php-scripts.com/20050929/28/</link>
		<comments>http://www.php-scripts.com/20050929/28/#comments</comments>
		<pubDate>Fri, 30 Sep 2005 00:21:57 +0000</pubDate>
		<dc:creator>TDavid</dc:creator>
		
		<category><![CDATA[MySQL]]></category>

		<category><![CDATA[Information]]></category>

		<guid isPermaLink="false">http://www.php-scripts.com/?p=28</guid>
		<description><![CDATA[To change MySQL databases within code use the mysql_select_db() function like this:

&#60;?php
&#160;mysql_select_db&#40;&#8216;db_2&#8242;, $mysql_link&#41;;
$query = &#8220;SELECT username from user where userid = &#8216;$user_id&#8217;&#8221;;
$result = mysql_query&#40;$query,$mysql_link&#41;;
&#160; &#160; &#160; &#160; if&#40;mysql_num_rows&#40;$result&#41;&#41; &#123;
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; $row = mysql_fetch_row&#40;$result&#41;;
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; $username = $row&#91;0&#93;;
&#160; &#160; &#160; &#160; &#125;
mysql_select_db&#40;&#8216;db_1&#8242;, $mysql_link&#41;;
?&#62;

This code [...]]]></description>
			<content:encoded><![CDATA[<p>To change MySQL databases within code use the mysql_select_db() function like this:</p>
<div class="codesnip-container" >
<div class="codesnip">&lt;?php<br />
&nbsp;<a href="http://www.php.net/mysql_select_db"><span class="kw3">mysql_select_db</span></a><span class="br0">&#40;</span><span class="st0">&#8216;db_2&#8242;</span>, <span class="re0">$mysql_link</span><span class="br0">&#41;</span>;<br />
<span class="re0">$query</span> = <span class="st0">&#8220;SELECT username from user where userid = &#8216;$user_id&#8217;&#8221;</span>;<br />
<span class="re0">$result</span> = <a href="http://www.php.net/mysql_query"><span class="kw3">mysql_query</span></a><span class="br0">&#40;</span><span class="re0">$query</span>,<span class="re0">$mysql_link</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><a href="http://www.php.net/mysql_num_rows"><span class="kw3">mysql_num_rows</span></a><span class="br0">&#40;</span><span class="re0">$result</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$row</span> = <a href="http://www.php.net/mysql_fetch_row"><span class="kw3">mysql_fetch_row</span></a><span class="br0">&#40;</span><span class="re0">$result</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$username</span> = <span class="re0">$row</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<a href="http://www.php.net/mysql_select_db"><span class="kw3">mysql_select_db</span></a><span class="br0">&#40;</span><span class="st0">&#8216;db_1&#8242;</span>, <span class="re0">$mysql_link</span><span class="br0">&#41;</span>;<br />
<span class="kw2">?&gt;</span></div>
</div>
<p>This code checks db_2 for the username by $user_id.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.php-scripts.com/20050929/28/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to join an ID list using IN MySQL function</title>
		<link>http://www.php-scripts.com/20050914/13/</link>
		<comments>http://www.php-scripts.com/20050914/13/#comments</comments>
		<pubDate>Thu, 15 Sep 2005 02:12:21 +0000</pubDate>
		<dc:creator>TDavid</dc:creator>
		
		<category><![CDATA[MySQL]]></category>

		<category><![CDATA[PHP 5.x]]></category>

		<category><![CDATA[PHP 4.x]]></category>

		<category><![CDATA[PHP 3.x]]></category>

		<guid isPermaLink="false">http://www.php-scripts.com/?p=13</guid>
		<description><![CDATA[How to create a query list of ID numbers using join from an $array and put into a string that can be used in a MySQL query:

$id_numbers = array&#40;1,6,14,32,84,27,49,77&#41;;
$complist = join&#40;”,”, $id_numbers&#41;;
$query = “SELECT id from tablename WHERE id IN&#40;$complist&#41;”;

]]></description>
			<content:encoded><![CDATA[<p>How to create a query list of ID numbers using join from an $array and put into a string that can be used in a MySQL query:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="re0">$id_numbers</span> = <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="nu0">1</span>,<span class="nu0">6</span>,<span class="nu0">14</span>,<span class="nu0">32</span>,<span class="nu0">84</span>,<span class="nu0">27</span>,<span class="nu0">49</span>,<span class="nu0">77</span><span class="br0">&#41;</span>;<br />
<span class="re0">$complist</span> = <a href="http://www.php.net/join"><span class="kw3">join</span></a><span class="br0">&#40;</span>”,”, <span class="re0">$id_numbers</span><span class="br0">&#41;</span>;<br />
<span class="re0">$query</span> = “SELECT id from tablename WHERE id IN<span class="br0">&#40;</span><span class="re0">$complist</span><span class="br0">&#41;</span>”;</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.php-scripts.com/20050914/13/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

