Script Perfect

         Random snips of code and bugs

Archive for the ‘mySQL’ Category

PHP Database Class, The Right Way

Posted by Tim On September - 8 - 2009

How many times do your fingers type out the commands to run a query or fetch a row? If you are performing database tasks on the majority of your pages and you have not simplified the process then you need to keep reading. Developing a database class is not very difficult, in fact there are plenty of them out there which can set you on your way. Once you start using them you will most likely never go back.

A database class should be thorough, simple, and save you time. A single command to connect or disconnect as well as most of your common functions should be included. Do not re-invent the wheel if you have a large scale project, there are plenty of pre-build APIs which will handle much more than the examples given here. Below is a simple class which can get you up and running as well as examples of how to use it, let’s take a look:

Read the rest of this entry »

Social Networking Addiction

Posted by Tim On September - 7 - 2009

Hold on I’m Tweeting. See my comment on FB? Yep, I Dugg it and told my friends on Linkedin. How many different networking sites do we need? I will leave that to the masses to decide. The addiction to these popular networking sites is amazing. Just look at the competition with Facebook, Google and Microsoft, they are all trying to get the best street price on their new drug and get the masses addicted. It does not matter, almost everyone is hooked with no rehab in sight.

This is not really that important, utilizing these tools and becoming a dealer is where the traffic and money is hiding out. Search engine optimization is still an important factor but the modern algorithms of the most popular search engines utilize these mass gatherings of people. Getting your link across these networking meccas means massive traffic.

Read the rest of this entry »

Multiple Sites or Domains, One Server, One DB

Posted by Tim On September - 2 - 2009

While messing around with some of my other sites I ran into a major problem. I had developed a great deal of conent for the main site and thought it would be great to make a seperate site for mobile users. The new site would of course be much smaller and compact but still allow the majority of data from the main site to be viewed.

When I started developing the mobile siteĀ  hit a brick wall, I could not connect to the database on my main site even though both sites were on the same server. I tried connecting to localhost as well as the IP address, specifying the db name or calling it from the query. Needless to say it tooks hours to figure out what was going on so here is my solution.

Read the rest of this entry »

About Me

I am an independent web developer and webmaster of many sites. The main goal of Script Perfect is to provide answers to some of the hard to find questions when it comes to website design and coding.

Twitter