The purpose of this lab is to make sure everyone has a working Apache web server, MySQL, PHP stack that they can use in class.
The lab has three parts:
If you have a laptop, I encourage you to bring it to class and install the development stack on it. If you don’t have a laptop you should install the stack on a USB memory stick.
Please follow the Run Your Personal Wikipedia from a USB Stick
Through in-class demo
Here is the scoop on how to run the SQL commands described in the textbook.
mysql -u root -p (the -u root means username = root, the -p means prompt for a password.Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 28
Server version: 5.1.37 Source distribution
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear
the current input statement.
mysql> CREATE DATABASE gregs_list;
Query OK, 1 row affected (0.00 sec)
mysql> USE gregs_list;
Database changed
mysql> CREATE TABLE doughnut_list
-> (
-> doughnut_name VARCHAR(10),
-> doughnut_type VARCHAR(6)
-> );
Query OK, 0 rows affected (0.02 sec)
mysql> DESC doughnut_list;
+—————+————-+——+—–+———+——-+
| Field | Type | Null | Key | Default | Extra |
+—————+————-+——+—–+———+——-+
| doughnut_name | varchar(10) | YES | | NULL | |
| doughnut_type | varchar(6) | YES | | NULL | |
+—————+————-+——+—–+———+——-+
2 rows in set (0.01 sec)
mysql>
You can view what you have done using phpmyadmin (will demo in class).
In the xampp htdocs folder create a folder called test and in that folder create a file story.html with the following content.
<p>Share your story</p>
</body>
</html>
This is just standard static html. You should be able to view this file by pointing your browser to http://localhost/test/story.html
Now we are going to add some PHP code to this file. PHP code is delimited by the starting string <?php and the ending string ?> First, copy the file story.html to story.php (files that contain php code must end with .php). We are going to add a few lines to print out the standard ‘Hello World’:
<p>Share your story</p>
<?php
echo(“Hello World”);
?>
</body>
</html>
Point your browser to http://localhost/test/story.php to see the results.
Finally, here is a short php file that prints out lots of information about the XAMPP install.