<?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>Simply Breath Teching... &#187; PHP Scripts</title>
	<atom:link href="http://www.breathteching.com/category/php-scripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.breathteching.com</link>
	<description>Resources for PHP Programmers and Small Business Operators</description>
	<lastBuildDate>Mon, 26 Apr 2010 04:50:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>SWFUpload gets stuck at uploading&#8230;</title>
		<link>http://www.breathteching.com/2010/03/06/swfupload-gets-stuck-at-uploading/</link>
		<comments>http://www.breathteching.com/2010/03/06/swfupload-gets-stuck-at-uploading/#comments</comments>
		<pubDate>Sat, 06 Mar 2010 02:22:21 +0000</pubDate>
		<dc:creator>bretto36</dc:creator>
				<category><![CDATA[Coding Help]]></category>
		<category><![CDATA[PHP Scripts]]></category>

		<guid isPermaLink="false">http://www.breathteching.com/?p=41</guid>
		<description><![CDATA[Recently I came across a problem while installing SWFUpload on my latest site. I had the problem before but couldn&#8217;t remember what the solution was.
When I uploaded a file with SWFUpload on my mac (OSX 10.5) it would get stuck at the uploading&#8230; status




This was cause by my upload_url file not returning any text at [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I came across a problem while installing SWFUpload on my latest site. I had the problem before but couldn&#8217;t remember what the solution was.</p>
<p>When I uploaded a file with SWFUpload on my mac (OSX 10.5) it would get stuck at the uploading&#8230; status</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-1300158297655257";
/* 468x60, created 6/28/09 */
google_ad_slot = "9266821861";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>This was cause by my upload_url file not returning any text at all. Make sure when you set up the system that for every error case that some sort of output is displayed. And also on success.</p>
<p>In PHP I simply output the error message then die;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.breathteching.com/2010/03/06/swfupload-gets-stuck-at-uploading/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Can&#8217;t get image width or height using javascript in IE 7 and 8</title>
		<link>http://www.breathteching.com/2009/11/27/cant-get-image-width-or-height-using-javascript-in-ie-7-and-8/</link>
		<comments>http://www.breathteching.com/2009/11/27/cant-get-image-width-or-height-using-javascript-in-ie-7-and-8/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 02:00:43 +0000</pubDate>
		<dc:creator>bretto36</dc:creator>
				<category><![CDATA[Coding Help]]></category>
		<category><![CDATA[PHP Scripts]]></category>

		<guid isPermaLink="false">http://www.breathteching.com/?p=38</guid>
		<description><![CDATA[Came across this one whilst working with an TinyMCE plugin.
I had some additional css on the image i was trying to get the height and width of &#8211; display:none;




That&#8217;s the problem. Just use visibility:hidden; in your CSS and all will be fine in the world.
Oh just in case you are using the incorrect javascript as [...]]]></description>
			<content:encoded><![CDATA[<p>Came across this one whilst working with an TinyMCE plugin.</p>
<p>I had some additional css on the image i was trying to get the height and width of &#8211; display:none;</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-1300158297655257";
/* 468x60, created 6/28/09 */
google_ad_slot = "9266821861";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>That&#8217;s the problem. Just use visibility:hidden; in your CSS and all will be fine in the world.</p>
<p>Oh just in case you are using the incorrect javascript as well.</p>
<p>alert(document.getElementById(&#8216;imageId&#8217;).width);</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.breathteching.com/2009/11/27/cant-get-image-width-or-height-using-javascript-in-ie-7-and-8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Forms won&#8217;t submit in IE when pressing enter</title>
		<link>http://www.breathteching.com/2009/06/23/forms-wont-submit-in-ie-when-pressing-enter/</link>
		<comments>http://www.breathteching.com/2009/06/23/forms-wont-submit-in-ie-when-pressing-enter/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 05:48:52 +0000</pubDate>
		<dc:creator>bretto36</dc:creator>
				<category><![CDATA[Coding Help]]></category>
		<category><![CDATA[PHP Scripts]]></category>

		<guid isPermaLink="false">http://www.breathteching.com/2009/06/23/forms-wont-submit-in-ie-when-pressing-enter/</guid>
		<description><![CDATA[Hi All
I&#8217;ve come across this issue yet again. Realised I&#8217;d forgotten to post it the first time.
Instance 1 &#8211; Form has 1 text field, when pressing enter the form doesn&#8217;t submit correctly, either won&#8217;t submit, or won&#8217;t send submit button value through to php.




Solution -
if ($noOfTextFields == 1)
{
//fix IE bug where if there is only [...]]]></description>
			<content:encoded><![CDATA[<p>Hi All</p>
<p>I&#8217;ve come across this issue yet again. Realised I&#8217;d forgotten to post it the first time.</p>
<p>Instance 1 &#8211; Form has 1 text field, when pressing enter the form doesn&#8217;t submit correctly, either won&#8217;t submit, or won&#8217;t send submit button value through to php.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-1300158297655257";
/* 468x60, created 6/28/09 */
google_ad_slot = "9266821861";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>Solution -</p>
<p><code>if ($noOfTextFields == 1)<br />
{<br />
//fix IE bug where if there is only 1 text field you can't press enter to submit form (it doesn't send submit button name value pair)<br />
$output .= "&lt;input name='" . time() . "' style='display: none;' type='text' / &gt;";<br />
}</code></p>
<p>That should fix that instance</p>
<p>Instance 2 &#8211; Only seems to be happening in IE8 &#8211; When a form is either being hidden (using CSS display or visibility tags) or being creating dynamically when you press enter nothing will happen</p>
<p>Solution &#8211; add the following code to your form tag &#8211; Special thanks to Chris from <a href="http://chrisbegg.com">chrisbegg.com</a> for providing me with an example he used to solve the ajax problem</p>
<p><code>onkeypress=" var keycode; if (window.event) keycode = window.event.keyCode; else if (e) keycode = e.which; else return true; if (keycode == 13) {this.submit()}else {return true;}"</code></p>
<p>Make sure that it&#8217;s all on one line you know how javascript dislikes multiple lines.</p>
<p>Good luck to you all. If you find any other occurrences of this problem that aren&#8217;t covered here let me know</p>
]]></content:encoded>
			<wfw:commentRss>http://www.breathteching.com/2009/06/23/forms-wont-submit-in-ie-when-pressing-enter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Image Caching &#8211; Specifically for Firefox</title>
		<link>http://www.breathteching.com/2009/06/05/image-caching-specifically-for-firefox/</link>
		<comments>http://www.breathteching.com/2009/06/05/image-caching-specifically-for-firefox/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 04:59:16 +0000</pubDate>
		<dc:creator>bretto36</dc:creator>
				<category><![CDATA[Coding Help]]></category>
		<category><![CDATA[PHP Scripts]]></category>

		<guid isPermaLink="false">http://www.breathteching.com/2009/06/05/image-caching-specifically-for-firefox/</guid>
		<description><![CDATA[Ok so it&#8217;s Friday and it&#8217;s 2:45pm. So close to the weekend and i just spent an hour or so figuring out how to get my image caching to work on my thumbnails. Against all odds i have managed to get firefox to cache images properly &#8211; well maybe how i want it is a [...]]]></description>
			<content:encoded><![CDATA[<p>Ok so it&#8217;s Friday and it&#8217;s 2:45pm. So close to the weekend and i just spent an hour or so figuring out how to get my image caching to work on my thumbnails. Against all odds i have managed to get firefox to cache images properly &#8211; well maybe how i want it is a better term</p>
<p>So let me explain my thumbnail creator &#8211; Thumbercules, as i have named it (in reference to Gumbercules, a line said my Zoidberg on Futurama (Gumbercules, in reference to someone having the flexibility of Gumbi and the strength of Hercules)), dynamically created thumbnails at a certain height and width specified in the Url that i call eg http://www.domain.com/webimages/x/756/y/160/src/slideshows/images/4a288b1905e1b.jpg. It will check my thumb folder for an already created copy. If it finds one it will return the image from the folder. If not it creates the file then returns it.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-1300158297655257";
/* 468x60, created 6/28/09 */
google_ad_slot = "9266821861";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>What was happening with my previous caching method was that Firefox would download the image, if i pressed reload it would use the cached version it had. But if i pressed reload again it would download it again and start the process over again. It wasn&#8217;t recreating the image, only clearing the cache.</p>
<p>So numerous tests were performed until i was able to come up with the following:</p>
<p><code>function returnImageFile($fileName, $imageType)<br />
{<br />
$expires = 10800;<br />
header("Expires: " . gmdate("D, d M Y H:i:s", strtotime( "+$expires seconds")) . " GMT");<br />
header("Cache-Control: public, max-age=$expires, pre-check=$expires");<br />
header("Pragma: cache", true);<br />
if(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']))<br />
{<br />
// if the browser has a cached version of this image, send 304<br />
header("Last-Modified: " . gmdate('D, d M Y H:i:s', filemtime($fileName)).' GMT');<br />
header("HTTP/1.1 304 Not Modified");<br />
die;<br />
}else if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) &amp;&amp; (strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == filemtime($fileName)))<br />
{<br />
// option 2, if you have a file to base your mod date off:<br />
// send the last mod time of the file back<br />
header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($fileName)).' GMT',<br />
true, 304);<br />
header("HTTP/1.1 304 Not Modified");<br />
die;<br />
}else<br />
{<br />
header("Last-Modified: " . gmdate('D, d M Y H:i:s', filemtime($fileName)).' GMT');<br />
}<br />
switch ($imageType)<br />
{<br />
case '1':<br />
case 'gif':<br />
header("Content-type: image/gif");<br />
ob_start();<br />
readfile($fileName);<br />
$ImageData = ob_get_contents();<br />
$ImageDataLength = ob_get_length();<br />
ob_end_clean();<br />
header("Content-Length: ".$ImageDataLength);<br />
echo $ImageData;<br />
break;<br />
case '2':<br />
case 'jpg':<br />
case 'jpeg':<br />
header("Content-type: image/jpeg");<br />
ob_start();<br />
readfile($fileName);<br />
$ImageData = ob_get_contents();<br />
$ImageDataLength = ob_get_length();<br />
ob_end_clean();<br />
header("Content-Length: ".$ImageDataLength);<br />
echo $ImageData;<br />
break;<br />
case '3':<br />
case 'png':<br />
header("Content-type: image/png");<br />
ob_start();<br />
readfile($fileName);<br />
$ImageData = ob_get_contents();<br />
$ImageDataLength = ob_get_length();<br />
ob_end_clean();<br />
header("Content-Length: ".$ImageDataLength);<br />
echo $ImageData;<br />
break;<br />
}<br />
die;</code></p>
<p>This script returns the file with the size value as well as the correct headers to cache the file. If you don&#8217;t want to cache the image then you should change the approach slightly, i can&#8217;t see many times where you would require thumbnails to not be cached. But for other dynamically created images refer to my other post about creating non cached images. <a href="/2007/11/10/firefox-caches-images-when-it-shouldnt/">Firefox Caches Images when it Shouldn&#8217;t</a></p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-1300158297655257";
/* 468x60, created 6/28/09 */
google_ad_slot = "9266821861";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>If anyone has any points to make please do make them, i haven&#8217;t had a chance to test this well on IE or Safari. As they don&#8217;t have an easy to use plugin like firebug, which tells you when something is being returned from cache or not.</p>
<p>As always good luck with your programming, hopefully this saves someone some of the hassle, or at least saves someone more time then it took me to write this</p>
]]></content:encoded>
			<wfw:commentRss>http://www.breathteching.com/2009/06/05/image-caching-specifically-for-firefox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Function for dealing with quotes in input fields in HTML/PHP</title>
		<link>http://www.breathteching.com/2008/03/24/function-for-dealing-with-quotes-in-input-fields-in-htmlphp/</link>
		<comments>http://www.breathteching.com/2008/03/24/function-for-dealing-with-quotes-in-input-fields-in-htmlphp/#comments</comments>
		<pubDate>Mon, 24 Mar 2008 10:09:57 +0000</pubDate>
		<dc:creator>bretto36</dc:creator>
				<category><![CDATA[PHP Scripts]]></category>

		<guid isPermaLink="false">http://www.breathteching.com/2008/03/24/function-for-dealing-with-quotes-in-input-fields-in-htmlphp/</guid>
		<description><![CDATA[Anyone who has coded html has come across this issue, you have an input field in your form but oh no! someone has entered a single or double quote into the value and they are now trying to edit it, and all you see in the input box is John\ instead of John\&#8217;s. It is [...]]]></description>
			<content:encoded><![CDATA[<p>Anyone who has coded html has come across this issue, you have an input field in your form but oh no! someone has entered a single or double quote into the value and they are now trying to edit it, and all you see in the input box is John\ instead of John\&#8217;s. It is one of those reoccuring issues which I face from time to time, but not anymore.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-1300158297655257";
/* 468x60, created 6/28/09 */
google_ad_slot = "9266821861";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>Every now and then i stumble across a new issue which my current method doesn&#8217;t solve. Talk about frustration, going through old code just to make sure you aren&#8217;t using that incorrect method. Heres something I whipped up tonight which I thought I should post asap.<br />
<code><br />
function form_encode($string)<br />
{<br />
/*make sure you remove the spaces in the first variable of the str_replace function, Word press doesn't seem to like to print out the htmlentity of the ampersand which is understandable*/<br />
<span style="font-size: 10px;">return str_replace("&amp; amp ;", "&amp;", (htmlentities(stripslashes($string), ENT_QUOTES)));</span><br />
}<br />
</code>I&#8217;m pleased with this solution, i&#8217;m hoping it&#8217;s not too computational intensive as it uses str_replace only once.</p>
<p>This function is especially effective when the data is being pulled from a database, but i found i needed a solution that can not only use data from a database and encode it properly but also if you are reusing $_POST variables, my forms if they fail reuse the same values, and i was getting alot of &#8220;John\ &#8221; errors but using the stripslashes then the htmlentities fixed it up really nice.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-1300158297655257";
/* 468x60, created 6/28/09 */
google_ad_slot = "9266821861";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>The reason for the str_replace is the htmlentities function will change the ampersand at the start of some special characters into the htmlentity &amp; amp ; which is what the function is supposed to do.. funny that. But a simple str_replace returns any double encoded htmlentites back into their original format, which means perfect display for us and easier forms from now on.</p>
<p>This has been tested on Firefox for Mac, Safara (Mac), will test on PC later. Thought I&#8217;d get this up asap for everyone. Will be interested to see if anyone finds it though.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.breathteching.com/2008/03/24/function-for-dealing-with-quotes-in-input-fields-in-htmlphp/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>PHP Redirect Code &#8211; with javascript</title>
		<link>http://www.breathteching.com/2007/10/27/php-redirect-code-with-javascript/</link>
		<comments>http://www.breathteching.com/2007/10/27/php-redirect-code-with-javascript/#comments</comments>
		<pubDate>Sat, 27 Oct 2007 11:05:54 +0000</pubDate>
		<dc:creator>bretto36</dc:creator>
				<category><![CDATA[PHP Scripts]]></category>

		<guid isPermaLink="false">http://breathteching.com/?p=5</guid>
		<description><![CDATA[Ever needed a redirect function that would know when to use javascript of php. Well the wait is over *crowd goes wild*&#8230;. sorry here it is
To use the function simply call it like so:
&#60;?php
$variables = array('firstvar' =&#62; $firstVar,
'secondvar' =&#62; "hello world");
REDIRECT("newPage.php?currentVar=123", $variables);
?&#62;

and here it is again if you missed it
and voila!
If you liked it let [...]]]></description>
			<content:encoded><![CDATA[<p>Ever needed a redirect function that would know when to use javascript of php. Well the wait is over *crowd goes wild*&#8230;. sorry <a href="http://breathteching.com/?attachment_id=6" rel="attachment wp-att-6" title="redirect function">here it is</a></p>
<p>To use the function simply call it like so:<br />
<code>&lt;?php<br />
$variables = array('firstvar' =&gt; $firstVar,<br />
'secondvar' =&gt; "hello world");<br />
REDIRECT("newPage.php?currentVar=123", $variables);<br />
?&gt;<br />
</code></p>
<p>and <a href="http://breathteching.com/?attachment_id=6" rel="attachment wp-att-6" title="redirect function">here it is</a> again if you missed it</p>
<p class="MsoNormal">and voila!</p>
<p>If you liked it let me know please.</p>
<p class="MsoNormal">I think there is still an issue with if the variable already exists in the target, i just haven&#8217;t had the time to work on it.<br />
Maybe i need to follow my tips in my other post &#8211; 4 Tips for working from home successfully</p>
]]></content:encoded>
			<wfw:commentRss>http://www.breathteching.com/2007/10/27/php-redirect-code-with-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>$_FILES Array and its Confusing Structure</title>
		<link>http://www.breathteching.com/2007/10/27/_files-array-and-its-confusing-structure/</link>
		<comments>http://www.breathteching.com/2007/10/27/_files-array-and-its-confusing-structure/#comments</comments>
		<pubDate>Sat, 27 Oct 2007 10:53:57 +0000</pubDate>
		<dc:creator>bretto36</dc:creator>
				<category><![CDATA[PHP Scripts]]></category>

		<guid isPermaLink="false">http://breathteching.com/?p=3</guid>
		<description><![CDATA[Have you ever noticed that the $_FILES array has an extremely odd structure that isn&#8217;t the usual type of array. The script i wrote helps to put it in an order so you can simply step through each one without having to write any sort of confusing loop.
It&#8217;s implementation can be seen below:

// a file [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever noticed that the $_FILES array has an extremely odd structure that isn&#8217;t the usual type of array. The script i wrote helps to put it in an order so you can simply step through each one without having to write any sort of confusing loop.</p>
<p>It&#8217;s implementation can be seen below:<br />
<code><br />
// a file field with the name image[] was passed<br />
//if it were a non array input it would simply be if (!empty($files['image']))...<br />
$files = change_file_array($_FILES);<br />
if (!empty($files))<br />
{<br />
foreach ($files['image'] as $key =&gt; $f)<br />
{<br />
if ($f['error'] == 0 &amp;&amp; $f['size'] &gt; 0)<br />
{<br />
//do somethign with file here<br />
}<br />
}<br />
}<br />
</code></p>
<p>I&#8217;m still getting used to wordpresses editor sorry about the indenting.</p>
<p>Click <a href="http://breathteching.com/wp-content/uploads/2007/10/change_file_array.zip" title="change_file_array.zip">here</a> download the script.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.breathteching.com/2007/10/27/_files-array-and-its-confusing-structure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
