<?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>Digital Epiphany Blog &#187; The Coding World</title>
	<atom:link href="http://www.digital-epiphany-designs.com/blog/category/the-coding-world/feed" rel="self" type="application/rss+xml" />
	<link>http://www.digital-epiphany-designs.com/blog</link>
	<description>Blog for coding examples and projects.</description>
	<lastBuildDate>Sat, 15 May 2010 15:44:06 +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>Prevent Spam without Captcha</title>
		<link>http://www.digital-epiphany-designs.com/blog/prevent-spam-without-captcha</link>
		<comments>http://www.digital-epiphany-designs.com/blog/prevent-spam-without-captcha#comments</comments>
		<pubDate>Mon, 10 May 2010 23:13:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[The Coding World]]></category>
		<category><![CDATA[captcha]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[spam]]></category>

		<guid isPermaLink="false">http://www.digital-epiphany-designs.com/blog/?p=112</guid>
		<description><![CDATA[The following will show you how to prevent spam without the use of those annoying captcha images. I use javascript, which according to W3C, approximately 95% of the people browsing the web have it enabled. The odds of one of your visitors having it disabled is slim. If it does concern you however, you could [...]]]></description>
			<content:encoded><![CDATA[<p>The following will show you how to prevent spam without the use of those annoying captcha images. I use javascript, which according to W3C, approximately 95% of the people browsing the web have it enabled. The odds of one of your visitors having it disabled is slim. If it does concern you however, you could always place a notice to turn on javascript before using the form or you could always use another method, just place the other method in &lt;noscript&gt; &lt;/noscript&gt; tags.</p>
<p>Below is how you could prevent spam with simple javascript.</p>
<p><strong>TESTED IN THE LATEST BROWSERS: Internet Explorer 8.x, Firefox 3.x, Chrome 4.x, Safari 4.x</strong></p>
<p>&nbsp;</p>
<p><strong>Step 1:</strong> Create a separate javascript file and link to it in the &lt;head&gt; section of your page. I will call my file &#8220;formvalidation.js&#8221; and I will link to it from my form page &#8220;form.html&#8221;.</p>
<p> Example of the &#8220;head&#8221; section of &#8220;form.html&#8221;:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p112code9'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p1129"><td class="code" id="p112code9"><pre class="html" style="font-family:monospace;">  &lt;head&gt;
    &lt;script language=&quot;JavaScript&quot; src=&quot;formvalidation.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt; 
  &lt;/head&gt;
  &lt;body&gt;
  Your form would be here.
  &lt;/body&gt;</pre></td></tr></table></div>

<p>&nbsp;</p>
<p><strong>Step 2:</strong> Remove the form&#8217;s <em>action=&#8221;"</em> attribute</p>
<p>    Some Spam bots will submit directly to the form&#8217;s source, this step prevents that.</p>
<p>    Example of the form&#8217;s attributes:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p112code10'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p11210"><td class="code" id="p112code10"><pre class="html" style="font-family:monospace;">&nbsp;
  &lt;form name=&quot;exampleform&quot; method=&quot;POST&quot; id=&quot;exampleform&quot;&gt;</pre></td></tr></table></div>

<p>&nbsp;</p>
<p><strong>Step 3:</strong> Add some simple requirements to our form. I will use first name and last name.</p>
<p>Example:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p112code11'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p11211"><td class="code" id="p112code11"><pre class="html" style="font-family:monospace;">&lt;input type=&quot;hidden&quot; id=&quot;req_id&quot; name=&quot;req_id[]&quot; value=&quot;first_name&quot;&gt;
&lt;input type=&quot;hidden&quot; id=&quot;req_id&quot; name=&quot;req_id[]&quot; value=&quot;last_name&quot;&gt;</pre></td></tr></table></div>

<p>&nbsp;</p>
<p><strong>Step 4:</strong> Add a hidden field called &#8220;human&#8221; and set its value to &#8220;0&#8243;. We will change this value once we determine a human is filling out the form.</p>
<p>Example:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p112code12'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p11212"><td class="code" id="p112code12"><pre class="html" style="font-family:monospace;">&lt;input type=&quot;hidden&quot; id=&quot;human&quot; name=&quot;human&quot; value=&quot;0&quot;&gt;</pre></td></tr></table></div>

<p>&nbsp;</p>
<p><strong>Step 5:</strong> On one of your required fields, add a javascript function to call once something is typed into it. This verifies that a human is filling out the form. I will place it on the &#8220;Last Name&#8221; field.</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p112code13'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p11213"><td class="code" id="p112code13"><pre class="html" style="font-family:monospace;">&lt;input type=&quot;text&quot; name=&quot;last_name&quot; id=&quot;last_name&quot; onchange=&quot;validateHuman('exampleform');&quot; /&gt;</pre></td></tr></table></div>

<p>&nbsp;</p>
<p><strong>Step 6:</strong> Make the form submit button execute a javascript function that will check all the required fields, verify that a human submitted the form, and then submit the form for processing.</p>
<p>Example:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p112code14'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p11214"><td class="code" id="p112code14"><pre class="html" style="font-family:monospace;">&lt;input type=&quot;button&quot; name=&quot;Submit&quot; value=&quot;Submit&quot; onclick=&quot;submitForm('exampleform');&quot; /&gt;</pre></td></tr></table></div>

<p>&nbsp;</p>
<p><strong>Step 7:</strong> Add the following Javascript to your Javascript file &#8220;formvalidation.js&#8221;. These two javascript functions, &#8220;validateHuman&#8221; and &#8220;submitForm&#8221; will do all the work of preventing spam.</p>
<p><strong>validateHuman</strong> &#8211; changes the &#8220;human&#8221; form element to another number once a person has typed into your required field.<br />
<strong><br />
submitForm</strong> &#8211; validates the required form elements have been filled in, checks to see the value of &#8220;human&#8221; has changed, and then submits the form for processing.</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p112code15'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p11215"><td class="code" id="p112code15"><pre class="javascript" style="font-family:monospace;">&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> submitForm<span style="color: #009900;">&#40;</span>frm<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #006600; font-style: italic;">//Check is the visitor's browser supports the javascript function</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">forms</span><span style="color: #009900;">&#91;</span>frm<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">//START function executed</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">//we will now check to see if all required fields were filled in</span>
    <span style="color: #003366; font-weight: bold;">var</span> error <span style="color: #339933;">=</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">forms</span><span style="color: #009900;">&#91;</span>frm<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">elements</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'req_id'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">null</span> <span style="color: #339933;">||</span> document.<span style="color: #660066;">forms</span><span style="color: #009900;">&#91;</span>frm<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">elements</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'req_id'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">//store all of the required fields into &quot;reqs&quot;</span>
		<span style="color: #003366; font-weight: bold;">var</span> reqs<span style="color: #339933;">=</span>document.<span style="color: #660066;">forms</span><span style="color: #009900;">&#91;</span>frm<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">elements</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'req_id[]'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #006600; font-style: italic;">//count the number of required fields</span>
		<span style="color: #003366; font-weight: bold;">var</span> nbr_fields <span style="color: #339933;">=</span> reqs.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>
        <span style="color: #006600; font-style: italic;">//set a variable &quot;req&quot; to make sure all the &quot;reqs&quot; stay true</span>
		<span style="color: #003366; font-weight: bold;">var</span> req <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #006600; font-style: italic;">//loop through all the required fields, making sure they are not blank</span>
		<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>nbr_fields<span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		  <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">forms</span><span style="color: #009900;">&#91;</span>frm<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">elements</span><span style="color: #009900;">&#91;</span>reqs<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">value</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">value</span>.<span style="color: #660066;">length</span> <span style="color: #339933;">&lt;=</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		   <span style="color: #006600; font-style: italic;">//the field is blank</span>
		   req <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		   <span style="color: #006600; font-style: italic;">//list what field has been left blank to inform the user</span>
		   <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>reqs<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'first_name'</span><span style="color: #009900;">&#41;</span> error <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\n</span> - First Name&quot;</span><span style="color: #339933;">;</span>
		   <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>reqs<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'last_name'</span><span style="color: #009900;">&#41;</span> error <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\n</span> - Last Name&quot;</span><span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">//if all required fields are filled in</span>
		<span style="color: #006600; font-style: italic;">//and the &quot;human&quot; form element has changed</span>
		<span style="color: #006600; font-style: italic;">//submit the form</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>req<span style="color: #339933;">==</span><span style="color: #003366; font-weight: bold;">true</span> <span style="color: #339933;">&amp;&amp;</span> document.<span style="color: #660066;">forms</span><span style="color: #009900;">&#91;</span>frm<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">elements</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'human'</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'42'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            document.<span style="color: #660066;">forms</span><span style="color: #009900;">&#91;</span>frm<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">action</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;http://somewebsite.com/submit.php&quot;</span><span style="color: #339933;">;</span>
			document.<span style="color: #660066;">forms</span><span style="color: #009900;">&#91;</span>frm<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">submit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Opps, it looks like some fields are blank:<span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: #339933;">+</span>error<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span>
     <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">//END function executed</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span> 
    <span style="color: #006600; font-style: italic;">//START the browser does not support the function</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Your browser lacks the capabilities required to run this script!<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>Please call 555-555-5555 and we will gladly take your information over the phone.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">//END the browser does not support the function</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> validateHuman<span style="color: #009900;">&#40;</span>frm<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	document.<span style="color: #660066;">forms</span><span style="color: #009900;">&#91;</span>frm<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">elements</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'human'</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;42&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>That&#8217;s it! Your form should now prevent spam bots from submitting directly to it. Below is just a total picture of how &#8220;form.html&#8221; will look according to this demo.</p>
<p>Example of form.html:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p112code16'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p11216"><td class="code" id="p112code16"><pre class="html" style="font-family:monospace;">&nbsp;
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;Example Form&lt;/title&gt;
&lt;script language=&quot;JavaScript&quot; src=&quot;formvalidation.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
&nbsp;
&lt;body&gt;
&nbsp;
&lt;form name=&quot;exampleform&quot; id=&quot;exampleform&quot; action=&quot;submit.php&quot; method=&quot;POST&quot;&gt;
&lt;input type=&quot;hidden&quot; id=&quot;req_id&quot; name=&quot;req_id[]&quot; value=&quot;first_name&quot;&gt;
&lt;input type=&quot;hidden&quot; id=&quot;req_id&quot; name=&quot;req_id[]&quot; value=&quot;last_name&quot;&gt;
&lt;input type=&quot;hidden&quot; id=&quot;human&quot; name=&quot;human&quot; value=&quot;0&quot;&gt;
First Name: &lt;input type=&quot;text&quot; name=&quot;first_name&quot; id=&quot;first_name&quot; /&gt;&lt;br /&gt;
Last Name: &lt;input type=&quot;text&quot; name=&quot;last_name&quot; id=&quot;last_name&quot; onchange=&quot;validateHuman('exampleform');&quot; /&gt;&lt;br /&gt;
&lt;input type=&quot;button&quot; name=&quot;Submit&quot; value=&quot;Submit&quot; onclick=&quot;submit_form('exampleform');&quot; /&gt;
&lt;/form&gt;
&nbsp;
&nbsp;
&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.digital-epiphany-designs.com/blog/prevent-spam-without-captcha/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Use PHP to proportionally scale an image</title>
		<link>http://www.digital-epiphany-designs.com/blog/use-php-to-proportionally-scale-an-image</link>
		<comments>http://www.digital-epiphany-designs.com/blog/use-php-to-proportionally-scale-an-image#comments</comments>
		<pubDate>Thu, 12 Nov 2009 19:06:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[The Coding World]]></category>

		<guid isPermaLink="false">http://www.digital-epiphany-designs.com/blog/?p=106</guid>
		<description><![CDATA[I wrote the following function to proportionally scale images that I was pulling from a directory. View Code PHP&#160; function img_size&#40;$img,$alt&#41; &#123; &#160; list&#40;$width,$height&#41; = getimagesize&#40;$img&#41;; &#160; $maxwidth = 140; //set max width here &#160; if &#40;$width &#62; $maxwidth&#41; &#123; $i = $width - $maxwidth; $x = $width - $i; $percent = $maxwidth/$width; &#125; else [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote the following function to proportionally scale images that I was pulling from a directory.</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p106code18'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p10618"><td class="code" id="p106code18"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> img_size<span style="color: #009900;">&#40;</span><span style="color: #000088;">$img</span><span style="color: #339933;">,</span><span style="color: #000088;">$alt</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #990000;">list</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$width</span><span style="color: #339933;">,</span><span style="color: #000088;">$height</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">getimagesize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$img</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000088;">$maxwidth</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">140</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//set max width here</span>
&nbsp;
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$width</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$maxwidth</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$width</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$maxwidth</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$x</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$width</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$i</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$percent</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$maxwidth</span><span style="color: #339933;">/</span><span style="color: #000088;">$width</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">else</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$x</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$width</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$percent</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000088;">$y</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$percent</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$height</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000088;">$img_src</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;img src=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$img</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; width=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$x</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; height=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$y</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; alt=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$alt</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; border=&quot;0&quot; /&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$img_src</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> img_size<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://somesite.com/image.jpg'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'some alt text'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #666666; font-style: italic;">//result &lt;img src=&quot;http://somesite.com/image.jpg&quot; width=&quot;140&quot; height=&quot;(proportionate to 140)&quot; alt=&quot;(alt)&quot; border=&quot;0&quot;&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.digital-epiphany-designs.com/blog/use-php-to-proportionally-scale-an-image/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL, UPDATE data into a database using CONCAT()</title>
		<link>http://www.digital-epiphany-designs.com/blog/mysql-update-data-into-a-database-using-concat</link>
		<comments>http://www.digital-epiphany-designs.com/blog/mysql-update-data-into-a-database-using-concat#comments</comments>
		<pubDate>Wed, 04 Nov 2009 18:46:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[The Coding World]]></category>

		<guid isPermaLink="false">http://www.digital-epiphany-designs.com/blog/?p=101</guid>
		<description><![CDATA[To insert data into a MySQL database while preserving the already existing data, you will just concatenate your new data to the end of your existing data. Below is an example of how to do it using the column &#8220;changelog&#8221; which is used to keep track of changes made to the row/record. View Code MYSQLUPDATE [...]]]></description>
			<content:encoded><![CDATA[<p>To insert data into a MySQL database while preserving the already existing data, you will just concatenate your new data to the end of your existing data.</p>
<p>Below is an example of how to do it using the column &#8220;changelog&#8221; which is used to keep track of changes made to the row/record.</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p101code21'); return false;">View Code</a> MYSQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p10121"><td class="code" id="p101code21"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">UPDATE</span> table1 <span style="color: #990099; font-weight: bold;">SET</span> changelog<span style="color: #CC0099;">=</span><span style="color: #000099;">CONCAT</span><span style="color: #FF00FF;">&#40;</span>changelog<span style="color: #000033;">,</span><span style="color: #008000;">&quot;new data&quot;</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">WHERE</span> id<span style="color: #CC0099;">=</span><span style="color: #008000;">'idnumber'</span></pre></td></tr></table></div>

<p>
If you would like the data that you are entering to appear at the beginning of the existing data, simply flip the concatenation, example:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p101code22'); return false;">View Code</a> MYSQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p10122"><td class="code" id="p101code22"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">UPDATE</span> table1 <span style="color: #990099; font-weight: bold;">SET</span> changelog<span style="color: #CC0099;">=</span><span style="color: #000099;">CONCAT</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">&quot;new data&quot;</span><span style="color: #000033;">,</span>changelog<span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">WHERE</span> id<span style="color: #CC0099;">=</span><span style="color: #008000;">'idnumber'</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.digital-epiphany-designs.com/blog/mysql-update-data-into-a-database-using-concat/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL DELETE with a Max() Subquery</title>
		<link>http://www.digital-epiphany-designs.com/blog/mysql-delete-with-a-max-subquery</link>
		<comments>http://www.digital-epiphany-designs.com/blog/mysql-delete-with-a-max-subquery#comments</comments>
		<pubDate>Tue, 03 Nov 2009 20:50:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[The Coding World]]></category>

		<guid isPermaLink="false">http://www.digital-epiphany-designs.com/blog/?p=98</guid>
		<description><![CDATA[Here is another nifty way to use a Subquery when deleting a record from your MySQL table. View Code MYSQLDELETE FROM table1 WHERE id = '1' &#38;&#38; saleid='345' &#38;&#38; slot = &#40;SELECT MAX&#40;slot&#41; FROM table1&#41;]]></description>
			<content:encoded><![CDATA[<p>Here is another nifty way to use a Subquery when deleting a record from your MySQL table.</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p98code24'); return false;">View Code</a> MYSQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p9824"><td class="code" id="p98code24"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">DELETE</span> <span style="color: #990099; font-weight: bold;">FROM</span> table1 <span style="color: #990099; font-weight: bold;">WHERE</span> id <span style="color: #CC0099;">=</span> <span style="color: #008000;">'1'</span> <span style="color: #CC0099;">&amp;&amp;</span> saleid<span style="color: #CC0099;">=</span><span style="color: #008000;">'345'</span> 
	                  <span style="color: #CC0099;">&amp;&amp;</span> slot <span style="color: #CC0099;">=</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #990099; font-weight: bold;">SELECT</span> <span style="color: #000099;">MAX</span><span style="color: #FF00FF;">&#40;</span>slot<span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">FROM</span> table1<span style="color: #FF00FF;">&#41;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.digital-epiphany-designs.com/blog/mysql-delete-with-a-max-subquery/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL INSERT with a Max()+1 Subquery</title>
		<link>http://www.digital-epiphany-designs.com/blog/mysql-insert-with-a-max1-subquery</link>
		<comments>http://www.digital-epiphany-designs.com/blog/mysql-insert-with-a-max1-subquery#comments</comments>
		<pubDate>Tue, 03 Nov 2009 20:47:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[The Coding World]]></category>

		<guid isPermaLink="false">http://www.digital-epiphany-designs.com/blog/?p=93</guid>
		<description><![CDATA[This was a pain in my ass to figure out so I figured I would post it here in case anyone else needs to insert a record using a Max()+1 Subquery. I only use the Max()+1 Subquery when the value you want to increase is not the primary key. View Code MYSQLINSERT INTO table &#40;row1, [...]]]></description>
			<content:encoded><![CDATA[<p>This was a pain in my ass to figure out so I figured I would post it here in case anyone else needs to insert a record using a Max()+1 Subquery.</p>
<p>I only use the Max()+1 Subquery when the value you want to increase is not the primary key.</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p93code26'); return false;">View Code</a> MYSQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p9326"><td class="code" id="p93code26"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">INSERT</span> <span style="color: #990099; font-weight: bold;">INTO</span> <span style="color: #990099; font-weight: bold;">table</span> <span style="color: #FF00FF;">&#40;</span>row1<span style="color: #000033;">,</span> row2<span style="color: #000033;">,</span> row3<span style="color: #FF00FF;">&#41;</span>
    <span style="color: #990099; font-weight: bold;">SELECT</span> 1 <span style="color: #CC0099;">+</span> <span style="color: #000099;">COALESCE</span><span style="color: #FF00FF;">&#40;</span><span style="color: #FF00FF;">&#40;</span><span style="color: #990099; font-weight: bold;">SELECT</span> <span style="color: #000099;">MAX</span><span style="color: #FF00FF;">&#40;</span>row1<span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">FROM</span> <span style="color: #990099; font-weight: bold;">table</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span> <span style="color: #008080;">0</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span> <span style="color: #008000;">'value2'</span><span style="color: #000033;">,</span> <span style="color: #008000;">'value3'</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.digital-epiphany-designs.com/blog/mysql-insert-with-a-max1-subquery/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Latitude and Longitude of a location using Javascript and Google</title>
		<link>http://www.digital-epiphany-designs.com/blog/latitude-and-longitude-of-a-location-using-javascript-and-google</link>
		<comments>http://www.digital-epiphany-designs.com/blog/latitude-and-longitude-of-a-location-using-javascript-and-google#comments</comments>
		<pubDate>Thu, 22 Oct 2009 18:54:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[The Coding World]]></category>

		<guid isPermaLink="false">http://www.digital-epiphany-designs.com/blog/?p=86</guid>
		<description><![CDATA[The following Javascript will help you acquire the latitude and longitude of a location (using an address, zip code, or city). Note: You will need to have a Google API key which is domain specific. Place the following code in the &#60;head&#62; section: View Code JAVASCRIPTvar geocoder; geocoder = new GClientGeocoder&#40;&#41;; &#160; function submitForm&#40;&#41; &#123; [...]]]></description>
			<content:encoded><![CDATA[<p>The following Javascript will help you acquire the latitude and longitude of a location (using an address, zip code, or city).</p>
<p>Note: You will need to have a <a href="http://code.google.com/apis/maps/signup.html" target="_blank">Google API key</a> which is domain specific.</p>
<p>Place the following code in the &lt;head&gt; section:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p86code29'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p8629"><td class="code" id="p86code29"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> geocoder<span style="color: #339933;">;</span>
geocoder <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> GClientGeocoder<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> submitForm<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> address <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;address&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;, &quot;</span> <span style="color: #339933;">+</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;city&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;, &quot;</span> <span style="color: #339933;">+</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;state&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;, &quot;</span> <span style="color: #339933;">+</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;zip&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
  geocoder.<span style="color: #660066;">getLocations</span><span style="color: #009900;">&#40;</span>address<span style="color: #339933;">,</span> getCoords<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> getCoords<span style="color: #009900;">&#40;</span>response<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>response <span style="color: #339933;">||</span> response.<span style="color: #000066;">Status</span>.<span style="color: #660066;">code</span> <span style="color: #339933;">!=</span> 200<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Unable to Create Lat and Lng for plotting.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
    place <span style="color: #339933;">=</span> response.<span style="color: #660066;">Placemark</span><span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> lat <span style="color: #339933;">=</span> place.<span style="color: #660066;">Point</span>.<span style="color: #660066;">coordinates</span><span style="color: #009900;">&#91;</span>1<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> lng <span style="color: #339933;">=</span> place.<span style="color: #660066;">Point</span>.<span style="color: #660066;">coordinates</span><span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
 <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Lat:&quot;</span><span style="color: #339933;">+</span>lat<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot; - Lng:&quot;</span><span style="color: #339933;">+</span>lng<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Here is the HTML that was used to pass the data:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p86code30'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p8630"><td class="code" id="p86code30"><pre class="html" style="font-family:monospace;">Address: &lt;input id=&quot;address&quot; name=&quot;address&quot; type=&quot;text&quot; /&gt;
&nbsp;
City: &lt;input id=&quot;city&quot; name=&quot;city&quot; type=&quot;text&quot; /&gt;
&nbsp;
State: &lt;input id=&quot;state&quot; name=&quot;state&quot; type=&quot;text&quot; /&gt;
&nbsp;
Zip: &lt;input id=&quot;zip&quot; name=&quot;zip&quot; type=&quot;text&quot; /&gt;
&nbsp;
&lt;input onclick=&quot;submitForm();&quot; type=&quot;button&quot; value=&quot;Submit&quot; /&gt;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.digital-epiphany-designs.com/blog/latitude-and-longitude-of-a-location-using-javascript-and-google/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Latitude and Longitude of a location using PHP and Google</title>
		<link>http://www.digital-epiphany-designs.com/blog/latitude-and-longitude-of-a-location-using-php-and-google</link>
		<comments>http://www.digital-epiphany-designs.com/blog/latitude-and-longitude-of-a-location-using-php-and-google#comments</comments>
		<pubDate>Thu, 22 Oct 2009 16:55:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[The Coding World]]></category>

		<guid isPermaLink="false">http://www.digital-epiphany-designs.com/blog/?p=40</guid>
		<description><![CDATA[The following PHP code will help you acquire the latitude and longitude of a location (using an address, zip code, or city). Note: Your will be required to have your own domain specific Google API key. View Code PHPif &#40;$_POST&#91;'address'&#93;&#41; &#123; &#160; $key = ' '; //you will need yo use your own domain specific API [...]]]></description>
			<content:encoded><![CDATA[<p>The following PHP code will help you acquire the latitude and longitude of a location (using an address, zip code, or city).</p>
<p>Note: Your will be required to have your own domain specific <a href="http://code.google.com/apis/maps/signup.html" target="_blank">Google API key</a>.</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p40code33'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p4033"><td class="code" id="p40code33"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'address'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #000088;">$key</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">' '</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//you will need yo use your own domain specific API key</span>
&nbsp;
<span style="color: #000088;">$address</span> <span style="color: #339933;">=</span> <span style="color: #990000;">stripslashes</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'address'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$addressurl</span> <span style="color: #339933;">=</span> <span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$address</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$location</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://maps.google.com/maps/geo?q=&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$addressurl</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&amp;amp;output=csv&amp;amp;key=&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">list</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$stat</span><span style="color: #339933;">,</span><span style="color: #000088;">$acc</span><span style="color: #339933;">,</span><span style="color: #000088;">$lat</span><span style="color: #339933;">,</span><span style="color: #000088;">$lng</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$location</span><span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;LAT:&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$lat</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; - LNG:&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$lng</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Below is the HTML code which used a form to submit the address to the above PHP.</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p40code34'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p4034"><td class="code" id="p40code34"><pre class="html" style="font-family:monospace;">&lt;form action=&quot;&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;;&quot; method=&quot;post&quot;&gt;
&lt;input name=&quot;address&quot; type=&quot;text&quot; /&gt;
&lt;input type=&quot;submit&quot; value=&quot;Submit&quot; /&gt;
&lt;/form&gt;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.digital-epiphany-designs.com/blog/latitude-and-longitude-of-a-location-using-php-and-google/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Format Phone Number Fields with PHP</title>
		<link>http://www.digital-epiphany-designs.com/blog/format-phone-number-fields-with-php</link>
		<comments>http://www.digital-epiphany-designs.com/blog/format-phone-number-fields-with-php#comments</comments>
		<pubDate>Mon, 09 Feb 2009 17:39:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[The Coding World]]></category>

		<guid isPermaLink="false">http://www.digital-epiphany-designs.com/blog/?p=29</guid>
		<description><![CDATA[Below is a function I wrote to take a phone number entered by a user and convert it into a desired format. The one shown below is 555-555-5555. View Code PHPfunction phn_numb&#40;$numb&#41; &#123; if &#40;!is_numeric&#40;substr&#40;$numb, 0, 1&#41;&#41; &#38;amp;&#38;amp; !is_numeric&#40;substr&#40;$numb, 1, 1&#41;&#41;&#41; &#123; return $numb; &#125; &#160; $chars = array&#40;' ', '(', ')', '-', '.'&#41;; $numb [...]]]></description>
			<content:encoded><![CDATA[<p>Below is a function I wrote to take a phone number entered by a user and convert it into a desired format. The one shown below is 555-555-5555.</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p29code37'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2937"><td class="code" id="p29code37"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> phn_numb<span style="color: #009900;">&#40;</span><span style="color: #000088;">$numb</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">is_numeric</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$numb</span><span style="color: #339933;">,</span> 0<span style="color: #339933;">,</span> 1<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #339933;">!</span><span style="color: #990000;">is_numeric</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$numb</span><span style="color: #339933;">,</span> 1<span style="color: #339933;">,</span> 1<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$numb</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$chars</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'('</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">')'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'-'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$numb</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$chars</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$numb</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$numb</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">//you must dial &quot;1&quot; before dialing this number</span>
<span style="color: #000088;">$numb</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$numb</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'-'</span><span style="color: #339933;">.</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$numb</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'-'</span><span style="color: #339933;">.</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$numb</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'-'</span><span style="color: #339933;">.</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$numb</span><span style="color: #339933;">,</span> 7<span style="color: #339933;">,</span> 4<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$numb</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$numb</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'-'</span><span style="color: #339933;">.</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$numb</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'-'</span><span style="color: #339933;">.</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$numb</span><span style="color: #339933;">,</span> 5<span style="color: #339933;">,</span> 4<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$numb</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Therefore to see it in action:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p29code38'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2938"><td class="code" id="p29code38"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$phonenumber</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">2345678901</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> phn_num<span style="color: #009900;">&#40;</span><span style="color: #000088;">$phonenumber</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//the resulting echo would be 234-567-8901</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.digital-epiphany-designs.com/blog/format-phone-number-fields-with-php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript broke with multiple line variables from PHP</title>
		<link>http://www.digital-epiphany-designs.com/blog/javascript-broke-with-multiple-line-variables-from-php</link>
		<comments>http://www.digital-epiphany-designs.com/blog/javascript-broke-with-multiple-line-variables-from-php#comments</comments>
		<pubDate>Tue, 05 Aug 2008 13:26:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[The Coding World]]></category>
		<category><![CDATA[broke]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[lines]]></category>
		<category><![CDATA[multiple]]></category>

		<guid isPermaLink="false">http://www.digital-epiphany-designs.com/blog/?p=27</guid>
		<description><![CDATA[I have several sites where I use a pop up table to display information if the user rolls over and image. Example, if the user wants to view notes on a certain client, they can roll over a little &#8220;note&#8221; image to view the notes about the client pulled from a SQL database. The code [...]]]></description>
			<content:encoded><![CDATA[<p>I have several sites where I use a pop up table to display information if the user rolls over and image. Example, if the user wants to view notes on a certain client, they can roll over a little &#8220;note&#8221; image to view the notes about the client pulled from a SQL database. The code I use for a message may be:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p27code43'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2743"><td class="code" id="p27code43"><pre class="javascript" style="font-family:monospace;">note<span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;&lt;?php echo $message; ?&gt;;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>That would work if $message was all one line. But  as with all notes fields, you can never determine when the person entering data hits &#8220;Enter&#8221;. If the person did hit enter, your javascript would be broke and it would look like this in the source code.</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p27code44'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2744"><td class="code" id="p27code44"><pre class="javascript" style="font-family:monospace;">note<span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;This is the start of the note field. I hit enter after this sentence twice.
&nbsp;
Then I started typeing again&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>This broke the Javascript. To fix this you can just swap the hidden special characters with a html line break.</p>
<p>Working code:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p27code45'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2745"><td class="code" id="p27code45"><pre class="javascript" style="font-family:monospace;">note<span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;&lt;?php echo str_replace(&quot;</span>\r\n<span style="color: #3366CC;">&quot;,&quot;</span><span style="color: #339933;">&lt;</span>br<span style="color: #339933;">&gt;;</span><span style="color: #3366CC;">&quot;, $message); ?&gt;;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>This would return:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p27code46'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2746"><td class="code" id="p27code46"><pre class="javascript" style="font-family:monospace;">note<span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;This is the start of the note field. I hit enter after this sentence twice&lt;br&gt;&lt;br&gt;;Then I started typeing again&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.digital-epiphany-designs.com/blog/javascript-broke-with-multiple-line-variables-from-php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Page Forwarding using Meta Tag</title>
		<link>http://www.digital-epiphany-designs.com/blog/page-forwarding-using-meta-tag</link>
		<comments>http://www.digital-epiphany-designs.com/blog/page-forwarding-using-meta-tag#comments</comments>
		<pubDate>Fri, 18 Jul 2008 17:22:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[The Coding World]]></category>
		<category><![CDATA[forwarding]]></category>
		<category><![CDATA[meta]]></category>
		<category><![CDATA[page]]></category>

		<guid isPermaLink="false">http://www.digital-epiphany-designs.com/blog/?p=26</guid>
		<description><![CDATA[This code goes in the &#60;Header&#62; along with all other Meta info. View Code HTML&#60;meta http-equiv=&#34;REFRESH&#34; content=&#34;0; url=page.php&#34;&#62;]]></description>
			<content:encoded><![CDATA[<p>This code goes in the &lt;Header&gt; along with all other Meta info.</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p26code48'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2648"><td class="code" id="p26code48"><pre class="html" style="font-family:monospace;">&lt;meta http-equiv=&quot;REFRESH&quot; content=&quot;0; url=page.php&quot;&gt;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.digital-epiphany-designs.com/blog/page-forwarding-using-meta-tag/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
