Showing only posts in the series PHP Tutorials

PHP: Using Ternary Operator Condition Checks
Ternary is a short way to write if/else condition checks on a single line, and allows you to perform condition checks inline with variable assignments and more...
Apr 5, 2012   Nick Vogt   Programming

PHP: Prevent MySQL Code Injection Exploits
The information in this post is outdated. Please use PDO with real (non-emulated) prepared statments to properly prevent MySQL injection.

Any data that comes from the client-side needs to be properly validated and escaped before using. This is extra important if you're using that data to form part of a database query. Always assume that your users will try to input incorrect information and special characters into fields, and do not rely on HTML or JavaScript to prevent this...
Apr 5, 2012   Nick Vogt   Programming

PHP: Avoid Using Undefined Variables and Indexes
PHP is a fairly loose programming language, which causes many new developers (and experienced ones) to get lazy. If you suppress errors, you can get away with ridiculous things like using undefined variables, without anyone being the wiser. But just because you can get away with it, doesn't mean you should...
Apr 5, 2012   Nick Vogt   Programming

PHP: Use Identical Operator When Comparing User Input (Equals vs Identical)
When comparing two values against each other, it is common to use the "equals" operator (==), and this is fine as long as you have control over the values that are being compared. But what if you're comparing user input against a value, such as in a sign-in script or captcha? Using the equals operator can potentially leave you open for security issues, since PHP handles comparisons between different data types non-intuitively...
Apr 1, 2012   Nick Vogt   Programming

PHP: Detect Mobile User Agent Using preg_match Regular Expression
Want a more reliable way to detect mobile visitors than the CSS media query? Using PHP, you can change the whole site or redirect users to a different site when they browse from a mobile device, or just change the CSS.

This method relies on the HTTP_USER_AGENT value in the $_SERVER super global. Since this value ultimately comes from the client's browser, it can be spoofed, though don't expect a large portion of visitors to know how. I wrote a post on how to spoof your user agent on Android for those curious...
Mar 23, 2012   Nick Vogt   Programming

Set up Apache, PHP, and MySQL on Windows
Here's a basic guide on setting up an Apache server with PHP and MySQL on your Windows computer to use as a developer environment. Sure, you could just download WAMP, but where's the fun in that?

If you currently have IIS setup with MySQL, you can leave MySQL installed. You will want to remove IIS prior to installing Apache though. It would require configuring beyond the scope of this guide to use both IIS & Apache concurrently. To remove IIS, you will want to choose the "Add/Remove Windows Components" or similar link on your respective version of Windows, which would be in the "Add/Remove Programs" or "Programs and Features" control panel...
Sep 26, 2011   Nick Vogt   Programming

Working with cross-platform newline characters & user form input
If your site accepts user input, it's a good idea to understand the differences in newline characters between platforms and how to handle them (and it's just good to know in general). Say your site is running on a Unix host and receives comments or posts from Windows clients. Any HTML textarea form input sent from the Windows clients will contain newline characters that do not match those native to the Unix host. Likewise, if your site runs on a Windows host, the occasional Linux or Mac user will be sending non-native newline characters as well...
Sep 26, 2011   Nick Vogt   Programming

MySQL Full-Text Search PHP Tutorial
MySQL's full-text search allows you to quickly search a table for single or multiple keywords from multiple columns. It does this by using an index on the columns that you want to search. There are a few limitations that you should know of. Indexed columns can only be CHAR, VARCHAR, or TEXT, MySQL does not by default index words that are less than 4 characters, and any word that appears in over 50% of rows is excluded from the results. There are also stop words...
Feb 22, 2011   Nick Vogt   Programming

PHP: Making a code block for a blog or forum
Having a code block allows you to display code without it being interpreted as HTML. Code blocks are used extensively on programming-related forums and web sites so users can show other users the code they use. Here is a simple code block...
Sep 16, 2010   Nick Vogt   Programming

PHP Redirect: How-to Guide
If you've been developing in ASP 3.0 (classic ASP) you may be used to calling the response.redirect() function whenever you need to redirect a user to a different page. You could call this function anywhere in the page, which was convenient. Now that you're using PHP, you may be a little confused about how to redirect. In PHP, you redirect using the header() function and it must be called before any HTML. Like so...
Feb 19, 2010   Nick Vogt   Programming



Categories

All Posts
Computer Hardware
PC Gaming
Programming
Web and Internet
Miscellaneous

Tags

youtube
minecraft
skyrim
call of duty
crysis
facebook
actionscript
php
javascript
tutorial

Series

ActionScript 3 Tutorials
› PHP Tutorials
Game Reviews