When inside of a loop, you can keep track of the iteration number of the loop (shown below is a simple for loop). Using that iteration number, you can calculate it’s modulus of some number (number left over after an even division). If that modulus is zero, you are at an even division of whatever [...]
Continue reading...tirsdag, marts 9, 2010
Kommentarer slået fra
jQuery is not always as it appears. There’s a lot of cool stuff going on under the surface, and there are many methods just waiting to be discovered, and many potential usages of jQuery’s API that you may not have considered before. In this article I’ll be taking you through a few of the not-so-obvious [...]
Continue reading...tirsdag, marts 9, 2010
Kommentarer slået fra
PHP Place the code bellow inside your theme’s function.php file. Don’t forget to change the “TwitterProfileName” with your twitter profile name. function parse_feed($feed) { $stepOne = explode("<content type=\"html\">", $feed); $stepTwo = explode("</content>", $stepOne[1]); $tweet = $stepTwo[0]; $tweet = str_replace("<", "<", $tweet); $tweet [...]
Continue reading...torsdag, marts 4, 2010
Kommentarer slået fra
Part 1 – Overview of Functions, Database & Files Overview In this tutorial we’ll be creating a very simple blog system. We won’t be using OOP yet in this tutorial. For creating a Blog using OOP in PHP, another more advanced tutorial will be written and posted as well. The same goes for creating a more advance [...]
Continue reading...onsdag, marts 3, 2010
Kommentarer slået fra
In this tutorial we’ll be retrieving data from form fields. To do this we’ll first create an example form. We’re using the POST method to send the form data in the first example. Will later explain what this means, and how we can then retrieve the data from the form fields. Also the GET method [...]
Continue reading...onsdag, marts 3, 2010
Kommentarer slået fra
Assumptions You have an HTML form with a variety of inputs. The action attribute of the form points to a PHP file that contains the code below. Notes about code This code starts by creating an array that holds the name of various inputs being submitted via a POST. getFormData() is then called, where the required fields are [...]
Continue reading...onsdag, marts 3, 2010
Kommentarer slået fra
1) Function for stripping out malicious bits <?php function cleanInput($input) { $search = array( '@<script[^>]*?>.*?</script>@si', // Strip out javascript '@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags '@<style[^>]*?>.*?</style>@siU', // Strip style tags properly '@<![\s\S]*?--[ \t\n\r]*>@' // Strip multi-line comments ); $output = preg_replace($search, '', $input); return $output; } ?> 2) Sanitization function Uses the function above, as well as adds slashes as [...]
Continue reading...torsdag, februar 25, 2010
Kommentarer slået fra
It has been a while since we’ve done a proper PHP & MySQL tutorial here, So today we are creating a simple, yet robust, file download tracker. Each file will have a corresponding row in the database, where the total number of downloads is saved. PHP will update the MySQL database and redirect the visitors to [...]
Continue reading...torsdag, februar 18, 2010
Kommentarer slået fra
Last week i wrote an article about disabling trackbacks and pingbacks in wordpress comments, but today instead of disabling them we will separate them from comments. To see how it looks you can check some of my articles here on wpCanyon. <?php if ($comments) : ?> <ol> <?php foreach ($comments as $comment) : ?> <li id="comment-<?php comment_ID() ?>" class='commentItem'> <!-- [...]
Continue reading...torsdag, februar 18, 2010
Kommentarer slået fra
It’s very important to secure your data in PHP correctly. Because if you don’t, your website is in risk of being harmed by SQL injections and other dangerous code injections, which you obviously don’t want. So to protect your website against these code attacks, this tutorial was written ;) This tutorial will explain the reasons to [...]
Continue reading...
onsdag, marts 10, 2010
Kommentarer slået fra