Category

Archive for the 'PHP' Category

PHP Upgrade breaks broken code

( PHP )

finebynature had a nasty error message being displayed yesterday..

Fatal error: Cannot re-assign $this in /home2/finebyn/public_html/classes/cart.php on line 28

That was it, all that was displayed on the site.
My first thought was - I really should have provided a nice fallback page for fatal errors
Looking back at the offending line of code - i’m surprised it Ever […]

PHP Generic database re-ordering function

( PHP )

This made sense when I was writing it, It may make someone’s life easier perhaps..
Edit:
// Generic re-ordering function that can be re-used
function move_db_item($table_name, $order_column_name, $parent_id_name, $parent_id, $child_id_name, $child_id, $direction) {
 
// Get the Order Number
$sql = “SELECT “.$order_column_name.” FROM “.$table_name.” WHERE “.$child_id_name.“=’”.$child_id.“‘”;
$result = $db->queryFetch($sql);
$order_no = $result[$order_column_name];

// Get the id of the row above or below it
$sql […]

PHP - XML transformation

( Usability and PHP )

One thing I am learning in Web Application Development is browsers poor support for new XML technologies like XSLT which is used to transform XML into other documents using a simple templating language, XSLT.
XSLT is wonderfully simple to understand, and XPath (similar to a selector in CSS) can target parts of the XML document to […]

Evil Register Globals

( PHP )

In my previous post I confused myself it seems..
Register Globals was to blame - setting my session variables.. so my examples are just.. bad - here’s a better one.
<?php
 
session_start();
$_SESSION[‘name’] = ‘Mark’;
$name = “Raju Gautam”;
 
// Register globals ON will print ‘Raju Gautam’
// Register globals OFF will print ‘Mark’
echo $_SESSION[‘name’];
 
?>
That was more painful […]

OO, Encapsulation and breaking the rules

( Usability and PHP )

I’m making the shift from PHP4 style OO, to PHP5 style OO and I have a couple of beginner questions
The main differences that I can see are type constraints and encapsulation, in PHP5 you can set private, public, protected functions/variables and also be specific with type.
// PHP4
class SpiffyObject {
 
var […]

Generating Sitemaps - PHP, MySQL and Apache

( PHP )

I guess you’re all familiar with the Swinburne website but you may not know how it runs under the hood.
There is a web-based system that manages all the site’s information and menu items - This is all kept in a database that is used to create text files with HTML for all the menu’s - […]

Tips - powered by Wordpress

( Tech and yellowshoe and PHP )

I’m going Wordpress Crazy.. I just love the piece of software.
It’s just so simple to learn and customize, with the added benefit of a steady community of bloggers assisting the development and maintenance of future releases.
I created a theme for yellowshoe so I could more quickly make updates to my website, as well as make […]

ByteClub Registration

( CSS and Design and PHP )

I promised Clinton I would make this a long time ago so here it is..
Byteclub Registration Page
It has some basic error checking and emails Clinton the registration details..
Nothing too fancy but it works
The PHP:
<?php
$keys = array(’student_id’, ‘name’,‘email’,‘blog’,‘blogaddress’,‘wiki’, ‘comments’);
$mandatory = array(’student_id’, ‘name’,‘email’,‘blog’,‘wiki’);
$values = array();
$errs = array();
$values[‘blogaddress’] = “http://”;
if (isset($_POST[’submit’]) && $_POST[’submit’] == “Register Now”) {
foreach($keys […]