<?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>HelpSpa &#187; PHP</title>
	<atom:link href="http://helpspa.com/category/programming/php-p/feed/" rel="self" type="application/rss+xml" />
	<link>http://helpspa.com</link>
	<description>Computer Advice, Help. and Video Tutorials</description>
	<lastBuildDate>Thu, 12 Jan 2012 03:18:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Where do I go for PHP help?</title>
		<link>http://helpspa.com/programming/where-do-i-go-for-php-help/</link>
		<comments>http://helpspa.com/programming/where-do-i-go-for-php-help/#comments</comments>
		<pubDate>Fri, 22 Oct 2010 21:33:18 +0000</pubDate>
		<dc:creator>David W</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://helpspa.com/?p=1906</guid>
		<description><![CDATA[Q: Hi. I&#8217;m a PHP beginner and I need some help with PHP.  Where is the best place to go and learn php and to find php help? A: PHP is a great language for web programming and it would serve you well to learn it.  My first suggestion for learning PHP is to sit [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Q:</strong> Hi. I&#8217;m a PHP beginner and I need some help with PHP.  Where is the best place to go and learn php and to find php help?</p>
<p><strong>A: </strong> PHP is a great language for web programming and it would serve you well to learn it.  My first suggestion for learning PHP is to sit down with a good php book. Your best bet is to go to Amazon.com and search for PHP introductory books or books for PHP beginners, and based on the reviews their and the publishers you like, get a book.  For example, I&#8217;ve always liked Wrox books.  As much as people don&#8217;t like sitting down with a book, I think it&#8217;s important to really sit down and learn the fundamentals first.</p>
<p>For more specific php help, your best bet (once you&#8217;ve tried to work it out on your own, of course) is to go to one of many php forums.  I&#8217;ve always found the forums at <a href="http://www.devshed.com">DevShed.com</a> to be very helpful. If you do a search of their php forums you will likely find an answer.  Another good bet is to do a Google search for your specific problem or error.</p>
<p>Just remember, PHP is a very popular language, and while it can get frustrating at times like any other programming language, rest assured that you are probably not the only person to run into your specific problem &#8212; and an answer is out there!</p>
]]></content:encoded>
			<wfw:commentRss>http://helpspa.com/programming/where-do-i-go-for-php-help/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP/MySQL: How to Store Queries in a Separate Include File</title>
		<link>http://helpspa.com/programming/phpmysql-how-to-store-queries-in-a-separate-include-file/</link>
		<comments>http://helpspa.com/programming/phpmysql-how-to-store-queries-in-a-separate-include-file/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 02:55:38 +0000</pubDate>
		<dc:creator>David W</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://helpspa.com/?p=162</guid>
		<description><![CDATA[When implementing a php/mysql database (or any database for that matter), it&#8217;s sometimes easy to have all of the queries located in one place, as opposed to having them hard-coded into the pages. If the queries are hard-coded in, and the queries are reused on multiple pages (which they often are), it can be a [...]]]></description>
			<content:encoded><![CDATA[<p>When implementing a php/mysql database (or any database for that matter), it&#8217;s sometimes easy to have all of the queries located in one place, as opposed to having them hard-coded into the pages. If the queries are hard-coded in, and the queries are reused on multiple pages (which they often are), it can be a cumbersome task to update all of the queries. Having hard-coded queries also makes for larger, bulkier pages, which makes it harder to visualize the rest of the code on the page.</p>
<p>The following method is a simple solution to store all of your queries in one file and access them as needed. Please note that I am not advocating this as a &#8220;best practice&#8221; as there are many great articles on how to truly separate your presentation layer and your data layer, but this works.</p>
<p>I always have a <code>database.php</code> file that stores the connection data and has the related connection functions. So to continue with this &#8220;separation&#8221; concept, create a <code>queries.php</code> file.</p>
<p>To this file I simply add a variable that stores the specific query. So for example, I would add the following variables:</p>
<p><code>$getAuthors = "SELECT * FROM authors";</code><br />
<code>$getBooks = "SELECT * FROM book";</code></p>
<p>and so on with your queries.</p>
<p>Turning to the page that displays the results &#8212; the one that actually uses the query &#8212; (lets call it <code>authors.php</code>), I have the include statement:</p>
<p><code>include "queries.php";</code></p>
<p>and of course the code to access my database:</p>
<p><code>link_id = db_connect(); </code><br />
[here you can use whatever particular code you personally use to connect to a mysql database]</p>
<p>Then I simply populate the <code>$sql</code> variable (where I previously would have stored the actual code of the query), with the following:</p>
<p><code>$sql = $getAuthors;</code></p>
<p>To show you where it goes, I&#8217;m using the code: <code>$result=mysql_query($sql) or DIE(mysql_error());</code></p>
<p class="note">Again, the specifics don&#8217;t really matter other than that instead of hard-coding the sql query text for the $sql variable, you are simply referencing a variable in another file.</p>
<p>Now if you decide to update, change or modify the query, you can do it in one place &#8212; in the <code>queries.php</code> file.</p>
<p>So while this may not be the best method of handling this situation, it does work, and it does save time.</p>
]]></content:encoded>
			<wfw:commentRss>http://helpspa.com/programming/phpmysql-how-to-store-queries-in-a-separate-include-file/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Regular Expression for Single Letter &#8211; PHP</title>
		<link>http://helpspa.com/programming/php-p/regular-expression-for-single-letter-php/</link>
		<comments>http://helpspa.com/programming/php-p/regular-expression-for-single-letter-php/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 02:12:50 +0000</pubDate>
		<dc:creator>David W</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://helpspa.com/?p=145</guid>
		<description><![CDATA[I was working on a project where I needed to validate a querystring for a single letter &#8212; uppercase or lowercase. Since there is no php equivalent to the is_numeric() function, (e.g. a hypothetical is_alpha() function) I decided to use regular expressions to get the task done. I could have used ctype_alpha(), but that function [...]]]></description>
			<content:encoded><![CDATA[<p>I was working on a project where I needed to validate a querystring for a single letter &#8212; uppercase or lowercase. Since there is no php equivalent to the <code>is_numeric()</code> function, (e.g. a hypothetical <code>is_alpha()</code> function) I decided to use regular expressions to get the task done. I could have used <code>ctype_alpha()</code>, but that function wouldn&#8217;t account for the fact that I needed to find out if it&#8217;s a letter, AND if it&#8217;s a single character. I could have run two tests, but it was too much code and too many &#8220;if/else&#8221; statements. That&#8217;s why I went with RegExp.</p>
<p>I wanted to make sure that 1) there was only one character in the querystring, and 2) that the character was a letter &#8212; uppercase or lowercase.</p>
<p>Here&#8217;s the regular expression pattern  I used:</p>
<pre class="brush: php">$pattern = &#039;/^[A-Za-z]{1}$/&#039;;</pre>
<p>I used the following function to test the pattern, where <code>$variable</code> is the queryString that is passed from the calling page.  The &#8220;good&#8221; and &#8220;not good&#8221; output text are for diagnostic use and of course, will be removed later on.</p>
<pre class="brush: php">function letterCheck($variable) {
$pattern = &#039;/^[A-Za-z]{1}$/&#039;;
if (preg_match($pattern, $variable)) {
echo &quot;RegExp is good&quot;;
return 1;
}

else {
echo &quot;RegExp is not good. &quot; . $variable . &quot; does not match the criteria. &quot;;
return 0;
}
}</pre>
<p>That&#8217;s it.</p>
]]></content:encoded>
			<wfw:commentRss>http://helpspa.com/programming/php-p/regular-expression-for-single-letter-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

