Language Selection

English French German Italian Portuguese Spanish

Learn PHP - Getting dynamic

Filed under
Software

The whole point of coding in PHP instead of just using HTML files is to make everything dynamic. You want the pages to make themselves, so you can spend more time counting your loot. The ideal way to get content onto your pages is from a database. First of all, databases are, as the name suggests, great places to store data. Secondly, clients pay more if you use the words "database" and "dynamic" in the quote and invoice.

First off, we need to get our PHP program talking to the database. The primary time-waster when querying databases is waiting for the darn thing to establish a connection, so we'll do that right at the start and get it over with. We'll do this in a function so that you can type all this out once and just use it over and over, thus saving more time for sending out bills for your web development work:

function dbconnect($dbserver,$dbusername,$dbpassword,$dbname) {
$connection=mysql_connect($dbserver,$dbusername,$dbpassword) or die(mysql_error);
$db=mysql_select_db($dbname,$connection) or die(mysql_error());
}

The first line establishes the connection, and the second line selects the tectonic database. The die(mysql_error()) will display any errors and stop the program from executing further if something goes terribly, terribly wrong.
When you want to call this function, you'd use something like this:


dbconnect('localhost','tectonicdbuser','topsecret','tectonic');

Every time you call this function you will be instantly and magically connected to your database until you either explicitly disconnect or the page finishes processing. I don't bother to disconnect because, well, I'm lazy.

Right, now we want to get some info out of the database. We'll use the unique id number to identify which story we want, and go grab it before anyone notices.

Full Article.

More in Tux Machines

Leftovers: Gaming

Open Source Software: 10 Go To Solution for Small Businesses

While closed-source operating systems such as Windows and Mac OS may still dominate the OS market, not everyone can afford the high costs that they entail. For small- and medium-sized enterprises where every penny matters, taking advantage of open-source software such as Ubuntu’s Linux is a good bet to boost productivity and cost effectiveness. The fact that open-source softwares have evolved to become somewhat user-friendly and sleek also helps a good deal. Read more

Linux 4.11-rc8

So originally I was just planning on releasing the final 4.11 today, but while we didn't have a *lot* of changes the last week, we had a couple of really annoying ones, so I'm doing another rc release instead. I did get fixes for the issues that popped up, so I could have released 4.11 as-is, but it just doesn't feel right. It's not like another week of letting this release mature will really hurt. The most noticeable of the issues is that we've quirked off some NVMe power management that apparently causes problems on some machines. It's not entirely clear what caused the issue (it wasn't just limited to some NVMe hardware, but also particular platforms), but let's test it. Read more Also: Linux 4.11 delayed for a week by NVMe glitches and 'oops fixes' Linux 4.11 Pushed Back: 4.11-rc8 Released

Themes for Ubuntu

  • Flattiance is a Flat Fork of Ubuntu’s Ambiance Theme
    Flattiance is pitched as a “semi-flat fork” of the Ubuntu Ambiance theme. You know, the one that ships out of the box and by default. On the whole Flattiance keeps to the same color palette, with dark browns and orange accents, but it ditches the gradient in app headers in favour of a solid block.
  • A quick look at some essential GNOME Shell tweaks and extensions
    Now that Ubuntu is moving to GNOME Shell, many people will get a bit of a shock at how different the workflow is from Unity to Shell. Here’s a quick look at some essentials to get you going.