Monthly Archives: April 2018

Module 9 – Connection to MySQL and PHP for Web Programming Group

The assignment for web programming for this module was to make two connections from PHP to MySQL.

The web page I created for the assignment is here, containing links to pages for the first and second connections:

http://jered.0fees.us/module9/index.php

Connection 1

For the first connection, just pasting the code into a page and loading it naturally failed. After that I fixed a bad quote and added the closing “?>”, to get:

<?php
$db = mysql_connect("sql211.0fees.us","username","password");
if (!$db) {
	die("Database connection failed miserably: " . mysql_error());
}
?>

I replaced the MySQL server, username, and password in the code with the login information for my 0fees account.

After that, the page was blank when it loaded (because it didn’t throw an error). I added a sentence in HTML to the page just so I’d know for certain that the page had loaded.

That was pretty straightforward. I just needed to get my MySQL login information from the 0fees cPanel.

Connection 2

I had to tweak the first quotation mark in this code too, as well as set information like the login information and database info. I tried loading the page before creating the database and saw the expected error, with a notice about a failure to connect to the database. Then I made the database and no table, and got the third error in the PHP code, also as expected. Then I created the table and added some data, and the PHP code ran with no error messages (or output, so I added a line of text to the second page too). The code I used was (with my username and password removed):

<?php

//Step1

$db = mysql_connect("sql211.0fees.us","username","password");
if (!$db) {
	die("Database connection failed miserably: " . mysql_error());
}

//Step2

$db_select = mysql_select_db("username_module9",$db);
if (!$db_select) {
	die("Database selection also failed miserably: " . mysql_error());
}
?>
<html>
	<head>
		<title>Step 3</title>
	</head>
	<body>
		<?php

		//Step3

		$result = mysql_query("SELECT * FROM testdata", $db);
		if (!$result) {
		 die("Database query failed: " . mysql_error());
		}
		?>
		<p>If there were any errors, they will appear above this sentence.</p>
 </body>
</html>

The code ran fine, and I didn’t have any problems connecting to the database or creating data through PHPMyAdmin. The instructions in the slides for working with cPanel and PHPMyAdmin worked well.

Posted in Web Design Technologies | Comments Off

Module 9 – Web Design for Design Group

The assignment this week was to develop a blueprint for the website that my partner and I will create for the semester project. The assignment title suggested that the member of the team who will be primarily responsible for web design should create the blueprint. I will be primarily responsible for the web programming side.

The blueprint from my partner, Christian Williams, is reproduced below.

1. The websites objective is to sell vegetables and include nutritional information.

2. The audience is the consumers who would like to purchase vegetables.

3. The content of the site is a shopping area that displays vegetables and nutritional information. As well as information about the local farm.

4. The site will provide form functionality and a shopping cart.

5. Design elements are not finalized as of yet but as far as navigation the site will be very minimalistic and clear. It will offer a very clean user interface to buy vegetables. Images will be of fresh vegetables that accurately portray them. colors will be soft and rustic to match the theme of the farm.

Posted in Web Design Technologies | Comments Off