Monday, June 1, 2009

Leaning Reflection

From studying of this semester's DMT subject, I really learned a lot, not only technologies, but working ethics. And I relaized that it's not easy to do anything. Before, I have some woking experince, but only focus on the Oracle, and I thought it was very easy to build a website. When I made up my mind to build a vitural online book store, I met a lot of problems, some are really headache, cost me a lot of time. Anyway, I've learned a lot and really enjoy it.


• what did you learn
Although my virtual online book store is a very small system, when i finished it and reviewed it , I found I really learned a lot. From following aspects:

1. HTML,XHTML,CSS

Just using some basic HTML tag you can build your website on the internet, And then add the CSS, it can present a pefect layout, colors and fonts.

2.PHP

Before this subject, programming is my weak point, I never write a whole project programming. Now, I can write PHP embed in HTML, and using PHP to storing and retrieve data from file or database, using array write functions, and even some advance PHP features like Object-Oriented PHP.

3.MySQL

Beofe I have some experience with Oralce, So, leaning MySQL is not hard to me, but It still cost me some time to master it, because compare with ORACLE, MySQL is very inconvenience and it is open source as well , so not many powerful commerical software support it. However, mysql is common used, it's very good to learned it, when you build some small or medium system, it's the best choice. ohters database like SQLSever, Oralce and DB2 is so expenice.

4.Apahce

Because I tried to building running environment in my own laptop, so I download the Apache from official website and installed. Now I've Learned how to configue apache to support PHP and mysql. It looks very easy, but also cost me some time, because when I first try to run it , I met lots of problems and cannot fully set up, you should be very carful when you add or delete or modify any item in the configure files.

5.phpMyAdmin + Navicat 8

Before I learned Oracle, I used pl/sql developer, it's so powerful. But in terms of MySQL, there are not powerful commercial tools support it. The first I downloaded phpMyAdmin and extract to the apahce web service directory, but it didn't work , and then i spend a lot of time to read manual and tried to set it up. When it worked, i was very disappointed, it's not converince to use this admin system to operate database. After that, I searched the Google and found "Navicat 8", it's much better,it is said that the most powerful graphical database management and development software for MySQL, yes, it is, compare with phpMyAdmin.

6 powerdesign, visio

Although it is very small size system, I thing I should face it serious and I chose powerdesign to draw ER diagram and designed the database, after that, generated SQL file to directly run on MySQL database. What's more, I used Microsoft Visio to design the system structure and flow chart.

7 Dreamweaver + UltraEdit + Photoshop + HyperSnap

During the whole website developing time, I always use Dreamweaver, it's a so powerful tools and I love it very much. It help me reduce a lot of time to write code, because most of time it can generate code by itself. But you don't need to run Dreamweaver all the time, sometimes especially when you are testing system, you should use some light software, I chose UltraEdit. Another one , before I know I don't have any talent in photoshop, it makes me headache, but in order to draw some pictures for the webiste, I leaned a little bit about Photoshop, now i can eaily draw some basic pictures such as some icons, buttons and so on. The last one is HyperSnap, it's for the report, it's the best tool to cut the screenshots. It can make your work more effeciently if you learned how to use it, because if you use 'Print Screen' button from the keyborad, making one shotsreens should at least take half a minute, if you use HyperSnap, just one second, and it has more than tens cutting screenshot method.



Of couse, the above are some technologies and tools which are used during building website, I also leaned some program developing method, reseach method and making plans and so on.Abover all, a small system, and it can make big, you can learn a lot from them. I did it.


• how did you learn

When I made up my mind that this semester I should learn to build an online shopping website. Fistly, I downloaded and learned all the slides video from the lecturer who upload to online.uts.edu.au. And then, I borrowed some PHP,MYSQL books from the library, I'll recommend one book which is wrote by Luck Welling&Laura Thomson, and the book name is "PHP and MySQL Web Development", I think it's the best. I nealy spend the whole momth and follow the books' expmples. During studying it , I also tried to build the running environment in my laptop, and it's very easy to test the system codes and system results. and then I downled some open source PHP code and tried to run it and learn it. After learned PHP basic knowledge, I started to build my website, put theory into practise, during these time, I met a lot of problems, When I resolved them all, I found my programming skill and knowledge have up a level. Most of time, when I met the hard problems, I searched it from GOOLE, I can always find the artiles telling you how to deal with. Because using PHP and MySQL is not a cutting edge technologies, there are huge amount of artiles about them in the Internet if you 'GOOLE' them, some are excellent quailities, from them, you can advance quickly.


• what didn’t you learn

Although I learned a lot from building this website, I still feeling I have lots of things which I didn't learn. The technologies and tools which I mentioned in detail before, I just a newbie, and learned a in a shallow level, and still have a long long way to go. When you lean more , you feel you have more to lean. For example , how to use advance PHP features such as classes, functions to build reusable code PHP codes. Anyway, it's a good start.


• did you achieve your objectives?

Sure I did. I learned a lot and It's a very good start, I think based on these knowledge, I'll go further in the programming career.


• was any deviation justified?
Yes, it was.I complain time is short and it really flies, and I don't have enought time to fully stuy. From begin to the end, only three and a little more months, and I was busy all the time, because I have four subjects and I was working somethimes, also I spent a lot of time in IELTS(an english examination). Originally, I plan to build a more functional website, which would be like a real system , but I felt I don't have enough time to do this and then I cut some functions and only fulfilled some simple and basic features.

charlie server cannot support mysqli connection

So, yesterday evening, when i upload the whole website and found the carlie service cannot support mysqli connection, but i don't have enought time to modify the code, so i upload the souceCode to the ooowebsite, address is following:
http://felix.netau.net/

Sunday, May 31, 2009

recap how to configure phpmyadmin to administrate mysql in my laptop

first step: download zip file from the offical website and then extract to the apahce's htdocs' publish directory

secondly: 1.rename config.sample.inc.php from the phpmyadmin's main directory to config.inc.php and rewrite it,

the following is the config from my own:
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* phpMyAdmin sample configuration, you can use it as base for
* manual configuration. For easier setup you can use setup/
*
* All directives are explained in Documentation.html and on phpMyAdmin
* wiki .
*
* @version $Id: config.sample.inc.php 12304 2009-03-24 12:56:58Z nijel $
*/

/*
* This is needed for cookie based authentication to encrypt password in
* cookie
*/
$cfg['blowfish_secret'] = 'www.localhost.com'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

/*
* Servers configuration
*/
$i = 0;

/*
* First server
*/
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'aaaa'
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysqli if your server has it */
$cfg['Servers'][$i]['extension'] = 'mysql';

/* rajk - for blobstreaming */
$cfg['Servers'][$i]['bs_garbage_threshold'] = 50;
$cfg['Servers'][$i]['bs_repository_threshold'] = '32M';
$cfg['Servers'][$i]['bs_temp_blob_timeout'] = 600;
$cfg['Servers'][$i]['bs_temp_log_threshold'] = '32M';



/*
* End of servers configuration
*/

/*
* Directories for saving/loading files from server
*/
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';

?>


copy libmySQL.dll and php_mysql.dll these two files from php's directory to windows/system32 directory and then restart apache.

then run http://localhost/phpmyadmin to see the reuslt.

recap how to build Apach+php+mysql develop environment

This day, from DMT studying , i have learned how to build apach, php and mysql to running my own website.

this is a breif description for how to configure them.

first of all , download these three software from their website.

PHP:

copy php.ini-dist and rename to php.ini
looking for extension=php_mysql.dll then delete ";"
looking for extension_dir = “./” changed to your php's ext direction.
take my computer for example: extension_dir = "D:/project/PHP/ext"
add "D:\project\PHP\" to your environment variable's PATH

Then configure apache+php

looking for httpd.conf in Conf directory of apache

add these two line
LoadModule php5_module D:/PHP/php5apache2_2.dll
PHPIniDir “D:/PHP”

note: don't add "" to your php5_module, for example, i used
LoadModule php5_module “D:/PHP/php5apache2_2.dll” then my apache cannot start

looking for DirectoryIndex index.html, and then add index.php
looking for AddType application/x-gzip .gz .tgz
and then add these two lines:
AddType application/x-httpd-php .php
AddType application/x-httpd-php .html

Save httpd.conf.


In your publish directory, create a index.php with the following simple content
phpinfo();
?>

then resart apahce server, use address http://localhost/index.php to see the reuslt.

recap mysql commands which i've learned in DMT

To login (from unix shell) use -h only if needed.
# [mysql dir]/bin/mysql -h hostname -u root -p

$ mysql -h localhost -u user_name -ppassword
$ mysql -h localhost -u user_name -p
$ ******
$ mysql -h193.0.0.13 -u user_name -p db_name
$ ******


Create a database on the sql server.
mysql> create database [databasename];

Create a database on the sql server.
mysql> create database [databasename];

List all databases on the sql server.
mysql> show databases;

Switch to a database.
mysql> use [db name];

To see all the tables in the db.
mysql> show tables;

To see database's field formats.
mysql> describe [table name];

To delete a db.
mysql> drop database [database name];

To delete a table.
mysql> drop table [table name];


Creating a new user. Login as root. Switch to the MySQL db. Make the user. Update privs.
# mysql -u root -p
mysql> use mysql;
mysql> INSERT INTO user (Host,User,Password) VALUES('%','username',PASSWORD('password'));
mysql> flush privileges;

Change a users password from unix shell.
# [mysql dir]/bin/mysqladmin -u username -h hostname.blah.org -p password 'new-password'

Change a users password from MySQL prompt. Login as root. Set the password. Update privs.
# mysql -u root -p
mysql> SET PASSWORD FOR 'user'@'hostname' = PASSWORD('passwordhere');
mysql> flush privileges;

update User set Password=PASSWORD('newpassword') where User='root';



Set a root password if there is no root password.
# mysqladmin -u root password newpassword

import .sql command
mysql>use database;
mysql>source d:/mysql.sql;

add a new user:
grant all on databaseName.* to NewUserName@HostName identified by "password" ;
(this command will add a newuser and password )

if you wish the user can login in every computer, use '%' replace 'localhost'


grant usage on *.* to NewUserName@HostName identified by "password";
grant select,insert,update on databaseName.* to NewUserName@HostName identified by "password";
grant update,delete on mydb.TestTable to NewUserName@HostName identified by "password";

if want to give to others ,using after grant add "WITH GRANT OPTION"

Begin test my website. step1. Building real running environment in my own laptop--MySQL

This evening, i begin test website. I prepare to test it in my own laptop rather upload to others sevice, because using this way , can fully test my system.
Just now, I downloaded the "mysql-noinstall-5.1.32-win32.zip", it's the noinstall version, so, how to running this version and let it work, i should read the manual.
Follwing is the steps:

1.extract the archive to D:\project\mysql
2.start the server for the first time

D:\project\mysql\bin>mysqld --console
InnoDB: The first specified data file .\ibdata1 did not exist:
InnoDB: a new database to be created!
090531 23:41:23 InnoDB: Setting file .\ibdata1 size to 10 MB
InnoDB: Database physically writes the file full: wait...
090531 23:41:23 InnoDB: Log file .\ib_logfile0 did not exist: new to be created

InnoDB: Setting log file .\ib_logfile0 size to 5 MB
InnoDB: Database physically writes the file full: wait...
090531 23:41:23 InnoDB: Log file .\ib_logfile1 did not exist: new to be created

InnoDB: Setting log file .\ib_logfile1 size to 5 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
090531 23:41:24 InnoDB: Started; log sequence number 0 0
090531 23:41:26 [Note] Event Scheduler: Loaded 0 events
090531 23:41:26 [Note] mysqld: ready for connections.
Version: '5.1.32-community' socket: '' port: 3306 MySQL Community Server (GPL
)

3.start mysql from the windows command line
...\bin\mysqld

but i can stop MySQL server by executing this command:
...\bin\mysqladmin -u root shutdown

4. start mysql as a windows server
install the server as a service using this command:
...\bin\mysqld --install
then you will see your windows service list has increase one service call "mysql"
then
To make it easier to invoke MySQL programs, you can add the pathname of the MySQL bin directory to your Windows system PATH environment variable
eg. add "D:\project\mysql\bin\;" to the "path" in "system variables"

of course , if you want to remove a server that is installed as a service. first stop it if it is running by executing net stop mysql. then use the --remove option to remove it.
...bin\mysqld" --remove

You can test whether the MySQL server is working by executing any of the following commands:

C:\> "C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqlshow"
C:\> "C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqlshow" -u root mysql
C:\> "C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqladmin" version status proc
C:\> "C:\Program Files\MySQL\MySQL Server 5.1\bin\mysql" test

To permanently remove the old mysql service, execute the following command as a user with administrative privileges, on the command-line:

C:\> sc delete mysql
[SC] DeleteService SUCCESS

one very cool javascript menu

Today , in order to looking for a beautiful menu for my website, i search the interent and find this one, prepare using it for my website.

step1:Insert the following code into the (head) section of your page:


Step 2: Finally, insert the following into the (body) section of your page, right after the (body) tag itself: