skip to content rich footer

stevenclark.com.au

subscibe to the StevenClark.com.au rss feed

Archive for the 'snippets' Category

SQL ConnectToDatabase Function

Saturday, August 23rd, 2008

Carrying on from my last post about connecting to an SQL database using PHP, here are the functions I use to open and close database connections (Note: » just extends the line, you’ll need to remove that for this to work correctly).

// to open the database
function connectToDatabase ()	{
$link = mysql_connect("localhost", "database_name", »
                                  "database_password");
    if ($link && mysql_select_db("database_name"));
        return ($link);
	    return (FALSE);
}

// to close the database
function db_close($connecter)  {
    mysql_close($connecter);
}

It’s a good idea to keep these database connection functions in one place and then reuse them as you need, rather than repeating them everywhere.

Read the rest of this entry »

skip to top of page

Currently Reading

Mental Models by Indi Young (cover)Developing software from the user's perspective as opposed the organisational one is a critical area we need to work on as designers. I'm reading Mental Models by Indi Young, a book about understanding users' reasons for doing things and one system for understanding and designing for those reasons.

It's important to understand that when people visit your website they bring with them their own world view, motivations, experience and expectations. And, by working with those factors, we can improve our game significantly by providing them with what they want and need.