journal number four: connectDB()

Donna, you are not alone in the brutality. I keep geekily thinking “well, it was almost the end of the movie by the time Neo could make sense of the Matrix.” But I found reading all of your journals extremely helpful, nonetheless.

My plan this week will really start on the weekend, because I have some unexpected personal things I need to deal with this week and next (I thought since we are a team, I should let you know about my potential distraction).

But over the weekend, I plan to 1) re-read the sections in the chapters on PHP that I find confusing (ie that whole chunk about objects), 2) continue trying to make changes to the site, and barring that, running more of Nixon’s examples and playing around with them to see what I can modify, and 3) work on a secret program that I thought of that will be a present for you all if it works out! 4) work on applying some of Foucault’s ideas to the tool for my project critique to see if there is anything juicy to think about there.

AND 5) I am still behind on the Nixon chapters because for some reason, it takes me forever to read and understand it. I picked the shortest function to annotate for my journal this week because I felt like I could handle it, though I am jealous that those who posted before me seem to have done well with the longer ones. I can understand about 30% of the other functions that I looked at. Therefore! I plan to keep at the exercise over the weekend because I think it is good practice (perhaps not for my posture, though) and maybe try to put up another annotation in the next week (I am working on annotate.php) once I understand more. SLOW BUT STEADY!

I annotated the function Connect DB on netbeans itself so that I can keep the annotated copy for later when I inevitably forget. So instead of italics like Amelie and Kalervo, it will be in the //blahblahblah// format.

//the task that the below function performs is connecting to the

//database http://ecgtext.com/jiwa/ with

//a username and password that as been used with MySQL.//

function ConnectDB() {

///the function is declared as a user-defined function

//called “Connect DB” and the { opens the function//

$server = “localhost”;

$username = “ecgtextc_jiwa”;

$password = “jiwa665b”;

//variables for this function are defined: the variable $server is

//the string value “localhost,”

//the variable $username is also a string variable, “ecgtextc_jiwa”

//and the variable $password is another string, “jiwa665b”//

$link = mysql_connect ($server, $username, $password);

//this runs the built in php function called mysql_connect, which requires

//3 paramaters, the server, username and password of a MySQL server.

//They have already been defined above, because it is the specific file that

//Stephen created for me, but you could do as the textbook suggests and instead

//create a login.php file with the mysql login information in it and call require_once

//if you were creating functions for your own database with its own login info.

//this built-in function returns what the textbook calls an “identifier” to the server,

// but only if it is TRUE. If the user enters the wrong username and password,

// a FALSE is returned and that is where the next step comes in.//

if (!$link) {

// this line uses an if statement, where the logical operator ! represents a NOT.

//so this means, if $link returns a FALSE, then it should follow

//this alternate function, which is opened with { //

die(‘Could not connect: ‘ . mysql_error());

//so in the case that FALSE is returned, the die function is called to

// end the program. Inside the bracket, it gives the user a message that

// displays as ‘could not connect:’

// the period is string concatenation which appends the first string ‘could not

// connect:’ to the next part of the line,

//which is a call to another built-in function, that is mysql_error().

// I think this function is called to help the user figure out

//why there is an error, because what this function does is output the error text

//from the last called MySQL function, which was the mysql_connect function

//that is called above. so the output from this function would come after the

//colon. The second close bracket closes what will be displayed.//


//the die function is closed//


// the connectDB function is closed.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s