<?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>Richard Cummings &#187; Quick Solutions</title>
	<atom:link href="http://richardcummings.info/category/technologies-solutions/quick-solutions/feed/" rel="self" type="application/rss+xml" />
	<link>http://richardcummings.info</link>
	<description>Web Consulting, Project Management, Technical Training</description>
	<lastBuildDate>Fri, 27 Apr 2012 22:16:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>PHP/MySQL:  Query Date in DateTime Field</title>
		<link>http://richardcummings.info/phpmysql-query-date-in-datetime-field/</link>
		<comments>http://richardcummings.info/phpmysql-query-date-in-datetime-field/#comments</comments>
		<pubDate>Mon, 03 Oct 2011 17:41:18 +0000</pubDate>
		<dc:creator>Richard Cummings</dc:creator>
				<category><![CDATA[Quick Solutions]]></category>
		<category><![CDATA[Technologies/Solutions]]></category>
		<category><![CDATA[articles]]></category>
		<category><![CDATA[mysql php date datetime]]></category>
		<category><![CDATA[query date datetime]]></category>
		<category><![CDATA[query date in datetime field]]></category>

		<guid isPermaLink="false">http://richardcummings.info/?p=618</guid>
		<description><![CDATA[In this quick technical solution post, I will tell you how to query a date from a datetime field in PHP.]]></description>
			<content:encoded><![CDATA[<p>In this quick technical solution post, I will tell you <strong>how to query a date from a datetime field in PHP</strong>.</p>
<p>If you read the post <a href="http://richardcummings.info/php-get-date-7-days-one-weekago/">PHP get date 7 days ago</a>, you know that my project today called for querying a MySql database on a date 7 days in the past.  Well, having gotten a string that equals the date from 7 days ago, now I need to query the MySql database with that date.  However, the field is set at datetime.  Thus, querying on the date like you see in the code below yields no results:</p>
<pre class="brush: php; title: ;">
$oneweekago='2011-09-26';
mysql_query(&quot;SELECT * FROM table WHERE registration = '$oneweekago' &quot;)  // not working because time is in the datetime field
</pre>
<p>As you see in the coding comment above, this query does yield any results because it also wants a time.  So, we will use the MySQL <em>between</em> syntax to get the information that we want, which is all users who registered on the date of $oneweekago.</p>
<p>To do this, we create two new variables.  The first will be the time at the very start of that day one week ago and the second will be the last moment of that day.  As you see in the code below, we add these two variables and then we change the MySQL query to use the <em>between </em>syntax.  </p>
<pre class="brush: php; title: ;">
$oneweekago='2011-09-26';
$date1=$oneweekago.&quot; 00:00:00&quot;;
$date2=$oneweekago.&quot; 23:59:59&quot;;
mysql_query(&quot;SELECT * FROM table WHERE registration between '$date1' and '$date2'  &quot;)  // this now gets all users who registered that day
</pre>
<h2>Query Date in DateTime Field</h2>
<p>There are many people discussing the best way to get the date from a datetime in MySQL/PHP.  I found this way to be quick and easy.  I hope that you did too.</p>
<p>Cheers, Richard</p>
]]></content:encoded>
			<wfw:commentRss>http://richardcummings.info/phpmysql-query-date-in-datetime-field/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP:  Get Date 7 Days Ago-One Week Ago</title>
		<link>http://richardcummings.info/php-get-date-7-days-one-weekago/</link>
		<comments>http://richardcummings.info/php-get-date-7-days-one-weekago/#comments</comments>
		<pubDate>Mon, 03 Oct 2011 17:08:34 +0000</pubDate>
		<dc:creator>Richard Cummings</dc:creator>
				<category><![CDATA[Quick Solutions]]></category>
		<category><![CDATA[Technologies/Solutions]]></category>
		<category><![CDATA[articles]]></category>
		<category><![CDATA[php date 1 week ago]]></category>
		<category><![CDATA[php date 7 days ago]]></category>
		<category><![CDATA[php dates]]></category>

		<guid isPermaLink="false">http://richardcummings.info/?p=615</guid>
		<description><![CDATA[In this quick tech solution post, I will tell you how to get the PHP date 7 days ago, one week ago, or whenever you want.]]></description>
			<content:encoded><![CDATA[<p>In this quick tech solution post, I will tell you how to get the<strong> PHP date 7 days ago</strong>, <em>one week ago</em>, or whenever you want.</p>
<p>As I have said many times, I write these posts for both of us:  you and I.  When you are implementing tech solutions everyday, you are more like to forget than remember.  So, today, let us review how to get the PHP date from 7 days ago.</p>
<p>It is fairly easy to get a past date in PHP but, as always, remembering the syntax can be a bit of a challenge.  So, here we go.</p>
<h2>PHP:  Get a Past Date</h2>
<p>You can <em>get any past date you want in PHP</em> but, below, you will find the formula to get the date from 7 days/one week ago. </p>
<h3>PHP:  Get Date One Week Ago</h3>
<p>Ok, here is a little file that you can upload to your web server (I recommend Hostgator for PHP/MySQL) for testing if you like.  I have noted the line that gets you the date one week prior.</p>
<pre class="brush: php; title: ;">
 &lt;?
// get today's date
$today = date(&quot;Y-m-d&quot;);
echo &quot;Today is $today.&quot;;
echo &quot;&lt;br /&gt;&lt;br /&gt;&quot;;
$oneweekago=date('Y-m-d',strtotime('-7 days'));  // this gets one week ago in PHP
echo &quot;One week ago, the date was $oneweekago.&quot;;
?&gt;
</pre>
<h2>Summary:  Past Dates In PHP</h2>
<p>I hope this quick little tidbit about <strong>how to get past dates in PHP</strong> has been helpful.  Today, I had a quick project in which I needed to get the date from 7 days ago in PHP.  Hopefully, I will remember I wrote this so I can refer to it in the future. <img src='http://richardcummings.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>But wait, my project is not over.  I am doing a MySQL query where I have to get information from 1 week ago but the date is stored in a date time field&#8230;so I tell you how to do a query for date in a MySQL datetime field. </p>
]]></content:encoded>
			<wfw:commentRss>http://richardcummings.info/php-get-date-7-days-one-weekago/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP Mail:  Send Text and HTML Mail Through PHP Script</title>
		<link>http://richardcummings.info/php-mail-send-text-html-mail-multipart/</link>
		<comments>http://richardcummings.info/php-mail-send-text-html-mail-multipart/#comments</comments>
		<pubDate>Sat, 06 Aug 2011 02:12:36 +0000</pubDate>
		<dc:creator>Richard Cummings</dc:creator>
				<category><![CDATA[Quick Solutions]]></category>
		<category><![CDATA[Technologies/Solutions]]></category>
		<category><![CDATA[Web Consulting]]></category>
		<category><![CDATA[articles]]></category>
		<category><![CDATA[multipart php messages]]></category>
		<category><![CDATA[php mail]]></category>
		<category><![CDATA[text-html php mail]]></category>

		<guid isPermaLink="false">http://richardcummings.info/?p=592</guid>
		<description><![CDATA[In this article, I will show you how to use PHP mail to send a text/html message through a PHP script.
]]></description>
			<content:encoded><![CDATA[<p><strong>In this article, I will show you how to use PHP mail to send a text/html message through a PHP script.</strong></p>
<p>A client of mine today wanted to begin an email campaign to his subscriber list that included 10,000 people.  He wanted the email sent to be HTML for those who view mail with HTML enabled and text mail for those who don&#8217;t.</p>
<p>I have done this before but I had to brush up on how to send mail via PHP in both HTML and text format.  For you (and so I don&#8217;t have to brush up on this the next time), I will show you how to do this.</p>
<h2>Step 1:  Download PHPMailer</h2>
<p>PHPMailer is the best way to send mail using PHP.  Of course, you could code everything yourself.  But why?  <a href="http://phpmailer.worxware.com/">Download PHPMailer here.</a></p>
<p>After you have downloaded and extracted PHPMailer, install PHPMailer by copying the following files to your server as it states on the <a href="http://phpmailer.worxware.com/index.php?pg=install">install page</a>:  class.phpmailer.php, languages/phpmailer.lang-en.php.  </p>
<h2>Step 2:  Configure Your PHP Mail File</h2>
<p>PHP is an incredible scripting language but I am never quite satisfied with the examples that I am given.  This holds true with PHPMailer as well.  Thus, I am going to give you the exact PHP file that you can use and, hopefully, I will do a passable job adding comments and making this file pretty clear. </p>
<p>You can find the exact PHP file to use directly below, but first, let me give you a couple of notes.  Copy the information below into your favorite text editor and change the variables in the file (email names, addresses, text and html messages) .  Then, upload the file to your server and access it.  Voila&#8211;your mails will be sent.  Those who can read HTML messages will receive the HTML version and text-based email users will receive the text-based version.</p>
<h3>PHPMailer Sample File:  HTML and Text Message Sent Within Email</h3>
<pre class="brush: php; title: ;">
&lt;?

$recipientfirstname=&quot;Jim&quot;;
$recipientfirstlastname=&quot;Jim Truckee&quot;;
$recipientemailaddress=&quot;jimtruckee@yahoo.com&quot;;  // dont't email this guy...I just made up the address
$thesubject=&quot;$recipientfirstname -- I Have Great Information For You!&quot;;
$senderaddress=&quot;you@yourdomainname.com&quot;;
$sendername=&quot;YourFirstName YourLastName&quot;;

// html text message...change this to your liking
$myhtmlmessage=&quot;Hi $recipientfirstname, &lt;b&gt;I have great news&lt;/b&gt;!&lt;br /&gt;&lt;br /&gt;

I have just come across a website called &lt;a href=\&quot;http://richardcummings.info/\&quot;&gt;Richard Cummings&lt;/a&gt;.  You must check it out.  You will learn amazing things, like how to send an HTML or Text message through a PHP program!&quot;;
// end of html text message

// simple text messsage...change this to your liking
$mytextmessage=&quot;Hi $recipientfirstname, I have great news!&lt;br /&gt;&lt;br /&gt;

I have just come across a website called Richard Cummings:  http://richardcummings.info/ .  You must check it out.  You will learn amazing things, like how to send an HTML or Text message through a PHP program!&quot;;
$mytextmessage= str_replace(&quot;&lt;br /&gt;&quot;,'',$mytextmessage);  // this removes the &lt;br /&gt;'s or you can take them out manually

require_once 'class.phpmailer.php';

$mail = new PHPMailer(true); //defaults to using php &quot;mail()&quot;; the true param means it will throw exceptions on errors, which we need to catch

try {
  $mail-&gt;AddReplyTo($senderaddress, $sendername);  // you can change this to a &quot;do not reply address&quot;
  $mail-&gt;AddAddress($recipientemailaddress, $recipientfirstlastname);
  $mail-&gt;SetFrom($senderaddress, $sendername);
  $mail-&gt;Subject = $thesubject;
  $mail-&gt;AltBody = $mytextmessage; // optional - MsgHTML will create an alternate automatically
  $mail-&gt;MsgHTML($myhtmlmessage);
  $mail-&gt;Send();
  echo &quot;Message Sent OK\n&quot;;
} catch (phpmailerException $e) {
  echo $e-&gt;errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
  echo $e-&gt;getMessage(); //Boring error messages from anything else!
}
</pre>
<h2>Conclusion: Send Text and HTML Mail Through PHP Script</h2>
<p>By changing the variables in the file above, you should be able to successfully send a message using this script as long as your web host supports PHP.</p>
<p>If you know a bit of MySql, you see how I will  make this file a part of a loop and email everybody on the 10,000 person mailing list.  However, I will be doing just 200 per day at the clients request and I will accomplish this via a Cron Job&#8230;but that is for another discussion.</p>
<p>I hope that you are able to use the template file above to send text and html messages via the PHPMailer script.  </p>
<p>Cheers,<br />
Richard</p>
<h3>Appendix:  Text/HTML Email Web Pages You May Want To Visit</h3>
<p>Here are some pages that you may want to review regarding PHPMailer if you have any questions:</p>
<p><a href="http://phpmailer.worxware.com/index.php?pg=exampleamail">PHP Mailer Example</a><br />
<a href="http://www.learnphp-tutorial.com/Email.cfm">Sending Email with PHP and PHPMailer Tutorial</a></p>
<p>And a good discussion of text/HTML email can be found here:<br />
<a href="http://www.aweber.com/blog/email-template-design/should-i-use-text-or-html.htm">Should I Use Text or HTML Email?</a></p>
]]></content:encoded>
			<wfw:commentRss>http://richardcummings.info/php-mail-send-text-html-mail-multipart/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Find HTML Color Codes</title>
		<link>http://richardcummings.info/find-html-color-code/</link>
		<comments>http://richardcummings.info/find-html-color-code/#comments</comments>
		<pubDate>Wed, 01 Jun 2011 14:14:30 +0000</pubDate>
		<dc:creator>Richard Cummings</dc:creator>
				<category><![CDATA[Quick Solutions]]></category>
		<category><![CDATA[articles]]></category>
		<category><![CDATA[find HTML color codes]]></category>
		<category><![CDATA[HTML color code]]></category>
		<category><![CDATA[identify HTML color codes]]></category>

		<guid isPermaLink="false">http://richardcummings.info/?p=578</guid>
		<description><![CDATA[In this post, I will tell you how to quickly find the HTML color code of an image or any part of your web page. ]]></description>
			<content:encoded><![CDATA[<p>In this post, I will tell you how to quickly <strong>find the HTML color code</strong> of an image or any part of your web page.  </p>
<p>Whenever I find an easy tool that solves a big problem, I like to tell everyone about it.  I am interrupting my workday here to tell you about just such a tool.  </p>
<p>I was just looking for a quick way to<em> identify the HTML color code</em> of a particular color that I needed to implement for a webpage and I found a great tool that solves this problem quickly.</p>
<h2>Quickly Finding An HTML Color Code</h2>
<p>Don&#8217;t you just love it when a quaint little program meets your exact need and makes your work go so much quicker?  Well, I just found one and I have fallen for it quickly.  It&#8217;s a tool that I will likely use everyday.</p>
<p>It is a tool that quickly<strong> identifies HTML color codes</strong> and it is called the <a href="http://instant-eyedropper.com/">Instant Eyedropper</a>.  I want to give a big shout to the people who created this because it does exactly what it says and does not install a bunch of nonsense when loaded (as far as I have seen).</p>
<p>You can visit their website and quickly download and install this package to identify HTML color codes.  Once installed, the program sits in the system tray and you simply need to drag it over the color that you want identified.  Easy!</p>
<p>I use Windows 7 with dual monitors and only experienced one little problem.  I had to put the window from which I wanted to identify the HTML color in the primary window, but no big deal.</p>
<p>It&#8217;s a great little tool to <strong>identify HTML colors</strong> and I fully recommend it. </p>
<p>And, once again, thanks to the creators for providing this free tool which saved me a lot of time.    </p>
]]></content:encoded>
			<wfw:commentRss>http://richardcummings.info/find-html-color-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP String Split</title>
		<link>http://richardcummings.info/php-string-split/</link>
		<comments>http://richardcummings.info/php-string-split/#comments</comments>
		<pubDate>Thu, 03 Mar 2011 15:15:00 +0000</pubDate>
		<dc:creator>Richard Cummings</dc:creator>
				<category><![CDATA[Quick Solutions]]></category>
		<category><![CDATA[Technologies/Solutions]]></category>
		<category><![CDATA[articles]]></category>
		<category><![CDATA[PHP String Split]]></category>
		<category><![CDATA[quick solutions]]></category>
		<category><![CDATA[split a string]]></category>
		<category><![CDATA[Splitting a String in PHP]]></category>
		<category><![CDATA[splitting a variable]]></category>
		<category><![CDATA[technology solutions]]></category>

		<guid isPermaLink="false">http://richardcummings.info/?p=566</guid>
		<description><![CDATA[In this post, I am going to tell you how to do a PHP string split. While there use to be a PHP command called “PHP split“, it is no longer being supported so we will teach you how to do a PHP string split using the PHP explode command.]]></description>
			<content:encoded><![CDATA[<p>In this post, I am going to tell you how to do a <strong>PHP string split</strong>.  While there use to be a PHP command called &#8220;<a href="http://php.net/manual/en/function.split.php">PHP split</a>&#8220;, it is no longer being supported so we will teach you how to do a PHP string split using the <a href="http://php.net/manual/en/function.explode.php">PHP explode command</a>.</p>
<h2>How To Do a PHP String Split Using Explode</h2>
<p>Let us illustrate how to do a PHP string split by example.  I recently had a list of employees and job titles that was structured like this:</p>
<p>Jim Brown, Star Running Back<br />
Aaron Rodgers, Superbowl Winning Quarterback<br />
Tiger Woods, Golfer and Womanizer</p>
<p>I do not know who set up the list originally but it was not structured as we needed.  We wanted to add the information to a MySQL database with the full name in one column and the profession in the other.  In other words, we had to split the one PHP string into two that equaled the name and profession.</p>
<p>So, for example, we want to turn the variable $nameprofession=&#8221;Jim Brown, Star Running Back&#8221; into $name=&#8221;Jim Brown&#8221; and $profession=&#8221;Star Running Back&#8221;.</p>
<p>So, without further ado, let us see how we do this <em>PHP String split</em>.  </p>
<p>Here is the PHP file that accomplished this and I will discuss it below:</p>
<pre class="brush: php; title: ;">
&lt;?
// how to do a string split using explode

$nameprofession=&quot;Jim Brown, Star Running Back&quot;;
$explodeit = explode(&quot;, &quot;, $nameprofession);
$name=$explodeit[0];
$profession=$explodeit[1];
echo $name.&quot;&lt;br /&gt;&quot;;
echo $profession;

?&gt;
</pre>
<p>You can copy and paste this file into your favorite text editor (UltraEdit is mine), name it with a .php extension, and upload it to your web server to see it in action.</p>
<h2>PHP String Splitting With Explode: Explained</h2>
<p>Ok, so let&#8217;s take a look at what is happening in the file above.</p>
<p>We are exploding the variable $nameprofession using a <em>comma </em>and <em>space </em>as our delimiter and giving the result a name of $explodeit, which provides us an array as the result.  And, remember, arrays begin with &#8220;0&#8243; not &#8220;1&#8243;.  </p>
<p>Thus, $explodeit[0] equals the name of the person (which I then named $name for clarity) and $explodeit[1] equals the profession.  <em>NOTE:  The comma and space get removed.</em></p>
<p>The last couple of ECHO statements simply print out the result.</p>
<h2>PHP String Split:  Conclusion</h2>
<p>For me, PHP String Splits are best done using the PHP <em>explode </em>command.  </p>
<p>The most important element in doing an explode command is determining what you will explode.  In this case, as you saw, we used <em>comma space </em> as the delimiter.  In other cases, it may be a colon or semicolon or something of that nature.  </p>
<p>So, how do you this with a whole list of names and not just one?  How do you write all of this information to a MySQL database?  That will be a discussion for another post.  However, if you want to do some experimentation, you simply place the above commands in a php FOR or WHILE loop to change each entry and add it to the MySQL database on each run through.</p>
<p>Sometimes, it can be difficult to find solutions to what are seemingly simple PHP problems.  I hope this post has helped you discover how to do a <strong>PHP String Split</strong> quickly.  </p>
<p>If you want to be apprised of future PHP posts, simply subscribe to <a href="http://richardcummings.info/">Richard Cummings</a> below.  </p>
]]></content:encoded>
			<wfw:commentRss>http://richardcummings.info/php-string-split/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Delete First Character In String</title>
		<link>http://richardcummings.info/php-delete-first-character-in-string/</link>
		<comments>http://richardcummings.info/php-delete-first-character-in-string/#comments</comments>
		<pubDate>Thu, 03 Mar 2011 14:23:48 +0000</pubDate>
		<dc:creator>Richard Cummings</dc:creator>
				<category><![CDATA[Quick Solutions]]></category>
		<category><![CDATA[Technologies/Solutions]]></category>
		<category><![CDATA[articles]]></category>
		<category><![CDATA[PHP Delete First Character In String]]></category>
		<category><![CDATA[php substr instruction]]></category>
		<category><![CDATA[quick solutions]]></category>
		<category><![CDATA[Remove 1st character in string]]></category>
		<category><![CDATA[technology solutions]]></category>

		<guid isPermaLink="false">http://richardcummings.info/?p=561</guid>
		<description><![CDATA[In this post, I will show you how to delete the first character in a string in PHP. ]]></description>
			<content:encoded><![CDATA[<p>In this post, I will show you how to <strong>delete the first character in a string in PHP</strong>. </p>
<p>PHP is an incredible programming language but it is often difficult to find out how to do the most basic things.  For example, in this case, we want to <em>delete the first character in a PHP string</em> and we are probably directed to this <a href="http://php.net/manual/en/function.substr.php">SUBSTR PHP page</a>.  These PHP help pages provide us with a lot of information but often do not answer our basic questions.</p>
<p>So, today, I will tell you exactly how to delete the first character in a PHP string and give you an example page.  </p>
<p>(As I am a technical trainer by profession, I may be bringing many more of these PHP tutorials&#8211;I have been dealing with all sorts of PHP string issues of late.  If you would like these PHP tutorials automatically delivered to you, you may subscribe to my website, <a href="http://richardcummings.info/">Richard Cummings</a>, below.</p>
<h2>PHP:  How to Delete the First Character in a PHP String</h2>
<p>Ok, so let&#8217;s pick a term, any term.  How about &#8220;Richard enjoys PHP but finding answers to questions can be difficult.&#8221; ?</p>
<p>Now, our goal is to remove the &#8220;R&#8221;.  So, at the end of this lesson, I will be ichard.  </p>
<p>We can delete the first character of a string in PHP in three easy lines using the PHP <em>substr </em>utility.  </p>
<p>Here are the lines which I will explain below:</p>
<pre class="brush: php; title: ;">
&lt;?

// this file shows how to remove the first character of a string

$thename=&quot;Richard enjoys PHP but finding answers to questions can be difficult.&quot;;
$thename = substr($thename, 1);
echo $thename;

?&gt;
</pre>
<h3>Removing the First Character in PHP:  Explained</h3>
<p>This file does not need a whole lot of explanation.  Obviously, in the first line, we simply declare our variable.  Then, we use the PHP <em>substr</em> function to remove the first letter &#8220;R&#8221;.  </p>
<p>The key here is that the string characters begin at zero.  Thus, the &#8220;1&#8243; represents the second character of the string (very much like an array).  By simply placing this &#8220;1&#8243; there and nothing after it, we tell PHP to return the string starting at the second character and proceeding until the end of the string.</p>
<p>To see this file in action, simply copy and paste the text into your favorite text editor (UltraEdit is by far the best), name the file with a php extension, and then upload it to your web server.  </p>
<p>If you would like to then do some experimentation, change the number 1 to something else and see how things turn out.    Or, you may want to try to add a comma and then a number after 1 such as this:</p>
<pre class="brush: php; title: ;">$thename = substr($thename, 1,4); </pre>
<p>The number &#8220;4&#8243; above tells PHP to return 4 characters instead of defaulting to provide the <em>rest of the PHP string</em>.  </p>
<p>Now, how can you use <em>substr </em> to return the string &#8220;ichard enjoys PHP&#8221;.</p>
<p>With this simple little file, the <a href="http://php.net/manual/en/function.substr.php">PHP substr</a> page begins to make much more sense.  </p>
<p>Want to get really brave?  Throw in some negative numbers and see what happens&#8230;</p>
<h2>PHP Delete First Character In String:  Conclusion</h2>
<p>I hope that this page has helped everyone out there who is wanting to know <strong>how to use PHP to delete the first character in a string</strong>.  </p>
<p>Again, if you would like to be automatically emailed any PHP goodies to come, simply subscribe below.</p>
]]></content:encoded>
			<wfw:commentRss>http://richardcummings.info/php-delete-first-character-in-string/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Show Code In WordPress:  The Syntax Highlighter Plugin</title>
		<link>http://richardcummings.info/show-code-in-wordpress-the-syntax-highlighter-plugin/</link>
		<comments>http://richardcummings.info/show-code-in-wordpress-the-syntax-highlighter-plugin/#comments</comments>
		<pubDate>Fri, 07 Jan 2011 14:38:06 +0000</pubDate>
		<dc:creator>Richard Cummings</dc:creator>
				<category><![CDATA[Quick Solutions]]></category>
		<category><![CDATA[Technologies/Solutions]]></category>
		<category><![CDATA[articles]]></category>
		<category><![CDATA[quick solutions]]></category>
		<category><![CDATA[show code in WordPress]]></category>
		<category><![CDATA[syntax highlighter plugin]]></category>
		<category><![CDATA[techology solutions]]></category>

		<guid isPermaLink="false">http://richardcummings.info/?p=556</guid>
		<description><![CDATA[If you want to show code in WordPress, it is now very easy with a plugin called SyntaxHighlighter.]]></description>
			<content:encoded><![CDATA[<p>If you want to <strong>show code in WordPress</strong>, it is now very easy with a plugin called <a href="http://wordpress.org/extend/plugins/syntaxhighlighter/">SyntaxHighlighter</a>.</p>
<p>In my <a href="http://richardcummings.info/category/web-consulting/technologies-solutions/quick-solutions/">Quick Solutions</a> section,  it is often necessary for me to show code that I have used, usually in PHP.  This was always a hassle as I had to incorporate the text area element so that the code would actually show up as code and not be run or rewritten in a WordPress WYSIWIG format.  </p>
<p>All that is gone now with this awesome plugin called SyntaxHighlighter.  See it in action on the bottom of a page that I just created called <a href="http://richardcummings.info/apostrophe-input-form-php-mysql-the-easy-solution/">Apostrophe, Input Form, PHP, MySQL: The Easy Solution!</a>  It makes adding code to WordPress a snap.</p>
<p><a href="http://wordpress.org/extend/plugins/syntaxhighlighter/">SyntaxHighlighter</a> is one of the best plugins I have seen in a while.</p>
<p>I would like to give a big shout out to <a href="http://www.viper007bond.com/wordpress-plugins/syntaxhighlighter/">Alex</a>, the developer of this software.  Adding code to WordPress has always been a small nightmare and this plugin takes care of everything.  It&#8217;s a gem my friend.  Thanks a bundle, Richard.</p>
]]></content:encoded>
			<wfw:commentRss>http://richardcummings.info/show-code-in-wordpress-the-syntax-highlighter-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apostrophe, Input Form, PHP, MySQL:  The Easy Solution!</title>
		<link>http://richardcummings.info/apostrophe-input-form-php-mysql-the-easy-solution/</link>
		<comments>http://richardcummings.info/apostrophe-input-form-php-mysql-the-easy-solution/#comments</comments>
		<pubDate>Fri, 07 Jan 2011 14:12:03 +0000</pubDate>
		<dc:creator>Richard Cummings</dc:creator>
				<category><![CDATA[Quick Solutions]]></category>
		<category><![CDATA[Technologies/Solutions]]></category>
		<category><![CDATA[Apostrophe]]></category>
		<category><![CDATA[articles]]></category>
		<category><![CDATA[Input Form]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[quick solutions]]></category>
		<category><![CDATA[the solution]]></category>

		<guid isPermaLink="false">http://richardcummings.info/?p=550</guid>
		<description><![CDATA[In this article, I will tell you how to deal with the apostrophe not working in form data that writes to MySql using PHP. I do a lot of work involving input forms on PHP pages that write the input data to MySQL. Every time I do this, I have to account for the user [...]]]></description>
			<content:encoded><![CDATA[<p>In this article, I will tell you how to deal with the <strong>apostrophe not working</strong> in form data that writes to <strong>MySql using PHP</strong>.  </p>
<p>I do a lot of work involving input forms on PHP pages that write the input data to MySQL.  Every time I do this, I have to account for the user who puts in an apostrophe.  In most cases, it is intended.</p>
<p>This morning I was writing a form that allows users to enter movies.  What was one of the first movies that I tried to enter as a test?  <em>It&#8217;s Complicated</em>.  An appropriate title, no?</p>
<p>When you have not accounted for this apostrophe in your PHP file, you may receive a message that looks something like this:</p>
<p><textarea rows="2" cols="60">You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near &#8216;s</textarea></p>
<p>Anyway, I run into this quite a bit and each time I find myself fishing through my old projects or the Internet for a solution.  So, I write this solution as much for myself as for you <img src='http://richardcummings.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>And, thankfully, despite all the ramblings you may find on the Internet, the solution is quite easy. </p>
<p>Let&#8217;s have a look.  Assuming your variable is called $keyword, as mine is in the form I am working with right now, simply enter this after your $keyword variable:</p>
<pre class="brush: php; title: ;">$keyword = str_replace(&quot;'&quot;,&quot;''&quot;,$keyword);</pre>
<p>Dealing with apostrophes when you are working with form data in a PHP file that writes to a database can be a headache.  However, in the end, you just need that one line and you will be good to go.</p>
<p>Hope this helps.  Cheers and Happy New Year, Richard</p>
]]></content:encoded>
			<wfw:commentRss>http://richardcummings.info/apostrophe-input-form-php-mysql-the-easy-solution/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>PHP:  Convert Variable To Date</title>
		<link>http://richardcummings.info/convert-variable-to-date/</link>
		<comments>http://richardcummings.info/convert-variable-to-date/#comments</comments>
		<pubDate>Thu, 18 Nov 2010 13:58:47 +0000</pubDate>
		<dc:creator>Richard Cummings</dc:creator>
				<category><![CDATA[Quick Solutions]]></category>
		<category><![CDATA[Technologies/Solutions]]></category>
		<category><![CDATA[Web Consulting]]></category>
		<category><![CDATA[articles]]></category>
		<category><![CDATA[convert VARCHAR date]]></category>
		<category><![CDATA[Convert Variable To Date]]></category>
		<category><![CDATA[php convert variable to date]]></category>

		<guid isPermaLink="false">http://richardcummings.info/?p=543</guid>
		<description><![CDATA[In this article, I will review how to convert a variable that represents a date to an actual MySQL date column using PHP. Dealing with dates and times in MySQL and PHP is at once fascinating and frustrating. Everybody seems to store their date information with slight variances. Thus, everyone&#8217;s solution is slightly different. So, [...]]]></description>
			<content:encoded><![CDATA[<p>In this article, I will review how to <strong>convert a variable that represents a date to an actual MySQL date column using PHP</strong>.  </p>
<p>Dealing with dates and times in MySQL and PHP is at once fascinating and frustrating.  Everybody seems to store their date information with slight variances.  Thus, everyone&#8217;s solution is <em>slightly</em> different.</p>
<p>So, today I will show you how to take a date and time that are stored as text variables and convert them into dates to be placed in MySQL.  </p>
<p>In the article <a href="http://richardcummings.info/import-csv-file-into-mysql/">Import CSV File Into MySQL</a>, I illustrated how to import a .CSV file into MySQL.  This import stored the date and time as standard VARCHAR variables that look like this:  <em>October 26, 2010 | 7:30 p.m.</em>.  Here, I will show you how to convert these to a proper DATE/TIME format and store them in the MySQL table.  This process is actually very simple and can be done with just a few lines.</p>
<p>In the MySQL table, I created a new field called GAMEDATETIME and I marked this field with the <em>datetime</em> type.</p>
<p>I then created a php file which cycles through the table and gets the variables $gdate and $gtime, which again are VARCHAR variables that look like this:    <em>October 26, 2010 | 7:30 p.m.</em></p>
<p>So, the first thing we do (within the PHP loop) is create a combined date/time variable like this:<br />
$dateandtime=$gdate.&#8221; &#8220;.$gtime;<br />
This makes $dateandtime equal to a format like this:  October 26, 2010 7:30p.m.</p>
<p>Next, we use the strtotime php feature to put this into a UNIX timestamp like this:<br />
$newdatetime = strtotime( $dateandtime );<br />
<em>strtotime</em> is able to parse and read our combined variable perfectly!</p>
<p>Finally, to get this date data ready to store in our MySQL database in a format that it likes, we execute the following line of code in our PHP file, which uses the PHP date function to properly configure the date and time:<br />
$mydatetime = date(&#8216;Y-m-d H:i:s&#8217;, $newdatetime );</p>
<p>Now, we update MySQL using the UPDATE command as follows:<br />
$query1= &#8220;UPDATE <em>sqltable </em>SET <em>GAMEDATETIME</em>=&#8217;$mydatetime&#8217; WHERE x= x&#8221;;<br />
mysql_query($query1) or die(&#8220;Query failed: &#8221; . mysql_error());</p>
<p>This updates the GAMEDATETIME column with a properly stored game date and time, which makes this information infinitely more valuable than if it were stored in a standard text string!</p>
<p>I hope this helps.  Cheers,<br />
Richard</p>
]]></content:encoded>
			<wfw:commentRss>http://richardcummings.info/convert-variable-to-date/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Import CSV File Into MySQL</title>
		<link>http://richardcummings.info/import-csv-file-into-mysql/</link>
		<comments>http://richardcummings.info/import-csv-file-into-mysql/#comments</comments>
		<pubDate>Thu, 18 Nov 2010 13:03:45 +0000</pubDate>
		<dc:creator>Richard Cummings</dc:creator>
				<category><![CDATA[Quick Solutions]]></category>
		<category><![CDATA[Technologies/Solutions]]></category>
		<category><![CDATA[Web Consulting]]></category>
		<category><![CDATA[articles]]></category>
		<category><![CDATA[Import CSV File Into MySQL]]></category>
		<category><![CDATA[import text file MySQL]]></category>
		<category><![CDATA[import to MySQL]]></category>
		<category><![CDATA[MySQL import]]></category>

		<guid isPermaLink="false">http://richardcummings.info/?p=528</guid>
		<description><![CDATA[In this article, I will show you how to configure a CSV properly and then import the CSV file into MySql. A client of mine recently asked me if I could upload his .CSV file into a MySQL database. He runs a sports site and wanted to have the entire NBA schedule available in MySQL. [...]]]></description>
			<content:encoded><![CDATA[<p>In this article, I will show you how to <em>configure a CSV properly</em> and then <strong>import the CSV file into MySql</strong>.</p>
<p>A client of mine recently asked me if I could upload his .CSV file into a MySQL database.  He runs a sports site and wanted to have the entire NBA schedule available in MySQL.  He presented me with the text file and it looked like this:</p>
<p><TEXTAREA ROWS="6" COLS="70" READONLY>Tue. October 26, 2010 Miami Boston 7:30 p.m. Tue. October 26, 2010 Phoenix Portland 10 p.m. Tue. October 26, 2010 Houston L.A. Lakers 10:30 p.m. Wed. October 27, 2010 Boston Cleveland 7 p.m. Wed. October 27, 2010 Detroit New Jersey 7 p.m. Wed. October 27, 2010 Miami Philadelphia 7 p.m. Wed. October 27, 2010 New York Toronto 7 p.m.</TEXTAREA></p>
<p>Of course, the real file was 1,200 lines long but you get the idea.  </p>
<p>Now, when we import a .csv file into MySQL, we will need to tell it what separates each field and row.  A space?  Quotes?  In this particular file, a space separates everything so we need to parse it out.</p>
<p>First, I separated the lines.  I use UltraEdit for all of my quick text edits because, in my humble opinion, UltraEdit works miracles with text.  So, to do this within UltraEdit, we simply do a find replace on the term &#8220;p.m&#8221;(because it is the end of each line) like this:  Find:  <em>p.m.</em>, Replace with <em>p.m.^p</em>(which adds a new line).  Fortunately, all of the games had a p.m designation.    Now, our file looks like this:</p>
<p><TEXTAREA ROWS="6" COLS="70" READONLY>Tue. October 26, 2010 Miami Boston 7:30 p.m.<br />
Tue. October 26, 2010 Phoenix Portland 10 p.m.<br />
Tue. October 26, 2010 Houston L.A. Lakers 10:30 p.m.<br />
Wed. October 27, 2010 Boston Cleveland 7 p.m.<br />
Wed. October 27, 2010 Detroit New Jersey 7 p.m.<br />
Wed. October 27, 2010 Miami Philadelphia 7 p.m.<br />
Wed. October 27, 2010 New York Toronto 7 p.m.<br />
</TEXTAREA></p>
<p>Now, we clearly have an end marker for each row.  </p>
<p>As you can see, our fields in the database will be as follows:  DAY | DATE | AWAYTEAM | HOMETEAM | GAMETIME.  The database also has an <strong>auto-increment field</strong> and I will get to how to deal with that in just a moment.  </p>
<p>First, we need a delimiter for each of our fields.  You can see that a space separates each field, but there are also spaces within each field which is not good.  So, by simple replaces, I put a semi-colon between each field and eliminated the unneeded spaces elsewhere.  I also had to substitute a team number for the team name as this is how the database was structured (the TEAM NAME field was an integer that was taken as a foreign key from another table).</p>
<p>After doing these searches and replaces which only took a few minutes, we come up with our .CSV file which is ready to import.  It looks like this:</p>
<p><TEXTAREA ROWS="6" COLS="70" READONLY>Tue.;October 26, 2010;23;1;7:30p.m.<br />
Tue.;October 26, 2010;9;29;10p.m.<br />
Tue.;October 26, 2010;17;8;10:30p.m.<br />
Wed.;October 27, 2010;1;12;7p.m.<br />
Wed.;October 27, 2010;13;2;7p.m.<br />
Wed.;October 27, 2010;23;4;7p.m.<br />
Wed.;October 27, 2010;3;5;7p.m.</TEXTAREA></p>
<p>Now, the actual import of a .CSV file into MySQL is actually very easy in phpMyAdmin.  You simply select your database, click import, choose your file, select CSV as the file type and do your import.</p>
<p>However, this import did not work the first time.  Why?  There was an auto-increment GAMEID field in the MySQL table.  A lot of people ask <strong>how to deal with auto-increment fields when you import a .CSV file</strong> into a MySQL database.  The answer is actually very simple:  delete it and then re-create it after the import.  </p>
<p>So, after deleting the GAMEID auto-increment field, I imported the .CSV file, which populated the table with all of the games, and then I recreated the GAMEID field which self-populated, because it&#8217;s set to auto-increment.</p>
<p>In the end, <strong>importing a CSV file into MySQL</strong> is actually very easy.  The challenge is <em>preparing the .CSV file for import</em>.  However, with a little bit of UltraEdit magic, this is no problem.</p>
<p>Next, you may want to read <a href="http://richardcummings.info/convert-variable-to-date/">Convert Variable To Date</a> to see how I converted the dates and times of these games to their proper MySQL type so that they much more usable to us!</p>
]]></content:encoded>
			<wfw:commentRss>http://richardcummings.info/import-csv-file-into-mysql/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

