Computers and Technology
Posts tagged php
PHP tricks: substr()
Apr 19th
I’ve decided to start a new section on DavePCGuy that deals entirely with PHP tips & tricks. What’s great about that is that I show you some of the lesser known/used PHP functions, PHP uses in new creative ways.
First up is substr(), a simple yet rarely used function that cuts up your string. You tell it where to cut, and the function cuts. Now, you’ll be thinking, why use this?
Let me fist show you how it works.
More >
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:
When your project fails…
Jan 31st
So, let’s say you’re working on a project. It’s filled with your blood, sweat, and tears. You’ve been working on it through nights, barely sleeping at night, drinking large amounts of coffee during the day to stay up. Putting all into it. But then everything goes wrong.
Well, we’ve all been there, many times. If you’re a web-developer, it’s a natural part of your life. It’s a natural part of mine too. Let me tell you my story.
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 >
Where to learn PHP
Oct 11th
So you want to learn PHP, huh? I implore you to learn the HTML basics and some CSS first. CSS is not mandatory but it’ll come handy. HTML’s mandatory because of forms. Forms are essential for user data input and other actions in PHP.
Use these websites as guidelines, you’ll have to learn PHP on your own basically. Flip through them and whenever you can’t understand one part, get on another website and research it there. It’s how I’ve learned PHP. Get a book or two on PHP as well, they are structured very differently than online websites and some even feature a CD with example scripts. Most websites do not. Use this article wisely and most important of all, have fun.
More >