Computers and Technology
PHP and Scripting
Tutorials concerned with PHP and general scripting
Some useful PHP functions
Apr 15th
Recently, I have noticed that I use the same exact functions over and over again in PHP. I’ve actually set-up a complete function list that I tend to include in all of my projects. Here is an overview of some of them.
Let’s connect
You will need to connect to your database from time to time. It is important to do that in most projects that deal with MySQL, and you’ll probably do it frequently, on every page. Now, you can either delete that “function CustomConnect” and the braces and simply include() this part as a file orrr, just add this to your function list and call it up whenever you need it:
Creating a Blogging System (Part 2)
Jan 18th
Creating a Blogging system (part 1)
Jan 13th
Some time ago (a couple weeks), I created my own blogging system. No one told me how to do it and I didn’t read any tutorials on how to do it either so there were a few things I learned the hard way. As you know, Blogs are database-based, they’re all entries in a table.
You have an entry for the id, date, the content, and miscellaneous other information such as tags, and description. In this tutorial, I’d like to teach you how to do all that.
/* LET'S GET STARTED!*/
Mobile Websites (tips)
Jan 11th
I’ve recently started working on some mobile websites. You’ll notice that davepcguy.com has its own mobile alternative as do some other sites. Mobile devices are growing in number and gone are those days when internet was viewed only on the computer screen. WAP is not even used either so that old school coding is gone too.
These days, almost everyone has an iPhone or a BlackBerry, or a Palm device. Some of us even have other devices like PSPs, tablets, and others that require quite a bit different formatting. Here’s how to go about making your mobile website.
More >
Bit.ly API and adding URLs to your MySQL database
Dec 21st
In my last tutorial, I’ve touched on how to use the to.ly API and how to make automatic “Tweet it” buttons with a relevant message.
Well, this can get problematic if with every page refresh, your server sends out a request to the to.ly server for a short link. Pretty soon, you’ll be getting “Too Many Connections” and you’re screwed. Just like I was, so here’s an idea. How about we store those links in a database….automatically?
You see, it’s much easier to create a script that will request a shortlink, adds the link to the database, and then just call it up whenever you need it. It works perfectly well on my quote site. Basically, whenever you create a website with get-requests, tons of pages, and all that. You can use the following script to make it all work, automatically (again).
“Tweet This” and URL shortening API
Dec 19th
Alright, you’ve all seen those CRAZY “Tweet This” buttons on so many websites, (mainly wordpress). You may have also noticed that some just send you to twitter and you have to manually input the twitter message. Well, how about we just make a button that will automate all this for us?
I really do love it when I click on that button and twitter pops up with a pre-written message like “Check out this site : URL GOES HERE” or “Crazy CSS tutorial on backgrounds. Check it out: URL GOES HERE”, it makes it much easier for me to share my finds. Here’s a great demo.
Okay, I’m working on a new website and it has various posts on it that I want the readers to be able to automatically share on twitter. I also want to include a backlink so that their twitter followers can visit the actual article. Basically, here’s a tutorial on shortening URLs using API and for creating a twitter button.
Custom E-mail Form
Oct 15th
AH! So I have to create a custom e-mail sending form. He wants me to create a webform that will ask for a person’s name and e-mail address. Once those are input, an e-mail will be sent to the person’s e-mail account with a thank you message. Meanwhile, the website will reload with a custom coupon that bears their name. I’ll need it printable so I’ll have to add a print button as well.
Sounds simple enough, right?.. right?
More >
Setting up (Part 1)
Sep 15th
Here’s the first part of my “Setting Up” tutorials. It will teach you how to set up to learn PHP, and for web development. It is my own personally journey as well because I’m getting ready to make new WordPress themes. I’m using Windows XP, soon will be upgrading to Windows 7 (when it comes out) so most of my tutorials will be Windows-oriented.
Installing the Server Software
The best way to learn PHP and scripting is at home and without buying a domain nor paying for hosting. So let’s set up your computer as a server using XAMPP. XAMPP stands for X (as in a variable instead of an OS name) Apache, MySQL, PHP, and PERL. You can use any other alternative depending on your operating system. There’s also WAMP for Windows (I use this one) and MAMP for Mac. All are basically the same with small differences. I’ll show you how to use XAMPP because it’s the most cross-platform package. I’ll do an article on how to set up your Linux with XAMPP later.
A PHP poem
Sep 10th
We all know PHP is a lot of fun in on itself but let’s put some basic skills into making a creative script. Something, you probably wouldn’t even consider doing because it seems like a waste of time. Don’t laugh, I know what you’re thinking. And I know that you’ll laugh when you finish reading this article.
So how about we write a PHP poem.
Yeah, you think it’s silly, but so what? I found that making useless fun code is the best way to learn, at least for a beginner. It helps getting used to setting up the variables, doing switches, and making sense of forms. I wrote this piece of code when I started out with PHP a couple months ago. Now let’s start!
First, set up the variables. I decided to make my poem a bit “dynamic” (or rather interactive) so I used some different feelings that the user can choose from: More >
PHP error reporting script
Sep 5th
We’ve all encountered errors, especially during the synthesis of a new code. This is what a typical error looks like when you run it at a server at home:
Parse error: parse error in C:\directory\10_3.php on line 4
Here, we know that the error was a parse error and that it happened in a file called 10_3.php and it was on line 4. A parse error is typically just a missing semi-colon or a bracket. Nothing major, but it still triggers a fatal error. You can read all about the different errors and how to deal with them in the PHP manual or at this nifty Zend tutorial. I learned most of my PHP skills from that tutorial so read through it because it will definitely help you out.