Help - Search - Members - Calendar
Full Version: Asas PHP + Mysql - Complete Guide For PHP Newbies
NEO > Groups & Community > NEO Tech Talk
Kenshiin Humura
Install dan kofigurasi PHP4

Tutorial ini hanya sesuai untuk konfigurasi secara manual sahaja bukan untuk automatik seperti phptriad dan sebagai nya. Buat masa ini hanya di paparkan untuk konfigurasi windows sahaja..
Pertama anda perlu download ketiga-tiga server ini dahulu. Server yang digunakan dalam tutorial ini adalah Apache web server, PHP4 dan MySQL database. Ini adalah kerana ketiga-tiga nya adalah paling bersesuaian antara satu sama lain. Tetapi boleh juga digunakan untuk webserver yang lain seperti IIS,PWS atau xitami dan juga database yang lain seperti MS SQL, mSQL, sybase, Oracle dan sebagai nya.

Langkah pertama
Download PHP untuk windows precompiled binaries dari http://www.php.net/do_download.php?downloa...4.0.2-Win32.zip

Kemudian download Apache web server di http://www.apache.org/dist/binaries/win32/..._3_12_win32.exe
Kemudian download MySQL database di http://www.mysql.com/Downloads/Win32/mysql...3.22.34-win.zip

Langkah kedua

Unzip PHP4 yang telah di download kan itu dan extractkan ke C:\php.
Dan apabila selesai buka directory php tadi dan nama kan kembali file php.ini-dist kepada php.ini. Jikalau php3 namakan ke php3.ini.
Kemudian pindah kan fail php.ini ke directory C:\windows

Langkah ketiga

MySQL

Unzip MySQL installer dan run setup.exe. Install ke directory C:\mysql
Test MySQL..

MySQL Basics -- A Tutorial -

Permulaan

Ini adalah cara-cara basic untuk permulaan untuk mengenal bagaimanakah MySQL dijalankan .

SAYA sediakan Pengajaran disini hanya sesuai di dalam platform windows 95/98/2000/NT sahaja..

Windows Installation

1.Download program MySQL-Win32 version.
2.Buka Windows Explorer.
3.Cari fail yg telah di download tadi dan copy kedalam temporary directory.
4.Double click fail itu dan unzip.
5.Apabila fail ini telah di extract, pergi ke Explorer dan run Setup.exe.
6.Ikut arahan yg telah disediakan dlm installation program. Gunakan c:\mysql apabila extract. Jikalau anda ingin install kan ke directory lain, install dlm c:\mysql kemudian pindahkan. Apabila sudah dipindakan, gunakan --basedir option apabila panggil mysqld commands.
7.Buka MS-DOS Prompt tetingkap.
8.Tukarkan kepada c: drive jika tidak berada dalam C:
9.Kemudian masuk ke dlm directory MySQL dan bin seperti ini C:\>cd mysql\bin
10.Tukar kan nama daemon program ini: mysqld-shareware.exe kepada mysqld.exe
11.(Hanya untuk windows NT dan 2000 sahaja) Load kan MySQL daemon: c:\mysql\bin\mysqld --install
12.Close the DOS Prompt window: c:\mysql\bin\exit
13.Buka Services Manager
NT 4.0: Start Menu | Settings | Control Panel | Services
2000: Start Menu | Programs | Administrative Tools | Services
14.Highlight kan line dgn "MySql".
15.Jikalau "Startup" column ada "Manual" atau "Disabled, kemudian click kat "Startup" button, tick kat "Automatic" radio button dan click OK.
16.Click kat Start button.
17.Dan tutup Services Manager dan Control Panel.



Quick Tips untuk Windows Operating Systems yg lain.

Jikalau anda mengunakan Windows 95 or 98, jangan run mysqld --install. Operating systems ini tidak ade kemampuan untuk host sbg "service." Jadi anda perlu run MySQL sbg standalone application dgn menjalan kan command mysqld --standalone.


Membuat simple database dan mempaparkan structure

Buka MS-DOS Prompt window

masuk ke directory msql/bin


Membuat database baru dlm MySQL

C:\mysql\bin>mysqladmin create database01
Database "database01" created.


Mulakan MySQL

C:\mysql\bin>mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 22 to server version: 3.21.29a-gamma-debug

Type 'help' for help.


Buka database

mysql> use database01
Database changed


Buat table

Quote:


mysql> create table table01 (field01 integer,field02 char(10)smiley
Query OK, 0 rows affected (0.00 sec)



Paparkan tables

Quote:


mysql> show tables;
+----------------------+
| Tables in database01 |
+----------------------+
| table01 |
| table02 |
+----------------------+



Paparkan fields dlm table

Quote:


mysql> show columns from table01;
+---------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+----------+------+-----+---------+-------+
| field01 | int(11) | YES | | | |
| field02 | char(10) | YES | | | |
+---------+----------+------+-----+---------+-------+



dah berjaya!!

Masukkan Data kedalam Table

Masukkan record

mysql> insert into table01 (field01,field02) values (1,'first'smiley;
Query OK, 1 row affected (0.00 sec)


List kan semua records yg ade dlm table
Quote:


mysql> select * from table01;
+---------+---------+
| field01 | field02 |
+---------+---------+
| 1 | first |
+---------+---------+



Tambahan Fields

satu dlm satu masa

Quote:


mysql> alter table table01 add column field03 char(20smiley
Query OK, 1 row affected (0.04 sec)
Records: 1 Duplicates: 0 Warnings: 0



...lebih dari satu dlm satu masa
Quote:


mysql> alter table table01 add column field04 date,add column field05 time;
Query OK, 1 row affected (0.04 sec)
Records: 1 Duplicates: 0 Warnings: 0



"add column" mesti dikemukakan untuk setiap column.
Commas digunakan diantara setiap add column statement.
space digunakan selepas commas.


Quote:


mysql> select * from table01;
+---------+---------+---------+---------+---------+
| field01 | field02 | field03 | field04 | field05 |
+---------+---------+---------+---------+---------+
| 1 | first | NULL | NULL | NULL |
+---------+---------+---------+---------+---------+




Multi-line Command Entry

Ini adalah contoh SQL statement dimasuk kan ke dlm kedua2 cara:

Dlm satu Line

mysql> create table table33 (field01 integer,field02 char(30)smiley

Dalam banyak Line

mysql> create table table33
-> (field01
-> integer,
-> field02
-> char(30)smiley


Tambah kan Records ke dalam Table

Tambah record
Quote:


mysql> insert into table01 (field01,field02,field03,field04,field05) values
-> (2,'second','another','1999-10-23','10:30:00'smiley;
Query OK, 1 row affected (0.00 sec)


Standard format untuk date.

Standard date format is "smileyyyy-mm-dd".
Standard time format is "hh:mm:ss".

Value harus dimasukkan sbg "smileyyyymmdd" and times as "hhmmss".

Numeric values tidak perlu untuk quote. Column Data type adalah formatted untuk mengandungi (e.g. text, date, time, integer).

MySQL ade mengunnakan command buffer. Buffer ini menyimpan SQL statements yg telah dimasukkan tadi. Mengunnakan nye dpt mengelakkan daripada menaip semula commands sama berulangkali. Cuba lihat contoh di bawah ini.

Tambahkan record mengunnakan command buffer (and optional date and time formats)

1.Tekan arrow key duakali.
2.Tekan ENTER key.
3.Type kan values baru di dlm parentheses dan letakkan closing semicolon kat akhir.
(3,'a third','more foo for you',19991024,103004smiley
4.Tekan ENTER key.

Quote:


mysql> select * from table01;
+---------+-----------+------------------+------------+----------+
| field01 | field02 | field03 | field04 | field05 |
+---------+-----------+------------------+------------+----------+
| 1 | first | NULL | NULL | NULL |
| 2 | second | another | 1999-10-23 | 10:30:00 |
| 3 | a third | more foo for you | 1999-10-24 | 10:30:01 |
+---------+-----------+------------------+------------+----------+



Kemaskini Record yg ade

Ubah satu field dlm satu masa

Quote:


mysql> update table01 set field03='new info' where field01=1;
Query OK, 1 row affected (0.00 sec)



Tukar fields sekali byk dlm satu masa

Peringatan : Letakkan comma diantara setiap field yg di update.
Quote:


mysql> update table01 set field04=19991022, field05=062218 where field01=1;
Query OK, 1 row affected (0.00 sec)



Quote:



mysql> select * from table01;
+---------+-----------+------------------+------------+----------+
| field01 | field02 | field03 | field04 | field05 |
+---------+-----------+------------------+------------+----------+
| 1 | first | new info | 1999-10-22 | 06:22:18 |
| 2 | second | another | 1999-10-23 | 10:30:00 |
| 3 | third one | more foo for you | 1999-10-24 | 10:30:01 |
+---------+-----------+------------------+------------+----------+



Update sekali banyak

Quote:


mysql> update table01 set field05=152901 where field04>19990101;
Query OK, 3 rows affected (0.00 sec)



Quote:


mysql> select * from table01;
+---------+-----------+------------------+------------+----------+
| field01 | field02 | field03 | field04 | field05 |
+---------+-----------+------------------+------------+----------+
| 1 | first | new info | 1999-10-22 | 15:29:01 |
| 2 | second | another | 1999-10-23 | 15:29:01 |
| 3 | third one | more foo for you | 1999-10-24 | 15:29:01 |
+---------+-----------+------------------+------------+----------+



Buangkan Records

command untuk buang

mysql> delete from table01 where field01=3;
Query OK, 1 row affected (0.01 sec)

Quote:


mysql> select * from table01;
+---------+---------+----------+------------+----------+
| field01 | field02 | field03 | field04 | field05 |
+---------+---------+----------+------------+----------+
| 1 | first | new info | 1999-10-22 | 15:29:01 |
| 2 | second | another | 1999-10-23 | 15:29:01 |
+---------+---------+----------+------------+----------+




mysql> quit
Bye

Sile ke langkah seterusnya dimana anda akan di ajar configure apache

[pagbreak]

Langkah keempat

Apache

Run kan apache *.exe dan install ke C:\apache.
Kemudian pergi ke windows explorer dan edit file deoman httpd.conf didalan directory C:\apache/conf/ dan edit file ini dengan menggunakan text editor seperti notepad.

Dan edit seperti berikut :

Cari line yang tertulis =ServerName localhost dan buang tanda # didepannya.
Jika tidak ada tambah kan dibahagian servername atau line 233.

Kemudian tambah kan =ScriptAlias /php/ "c:/php/" yang terdapat di line 459.

Kemudian tambahkan =AddType application/x-httpd-php .php yang tedapat di line 620.

Kemudian tambahkan =Action application/x-httpd-php "/php/php.exe" yang terdapat di line 664

Cuba Apache
Langkah pertama run apache.exe dalam C:\apache.
Kemudian buat satu file baru. Buka notepad dan type kan seperti berikut

Quote:






dan save kan sebagai info.php. Kemudian letakan file ini didalam directory C:\apache\htdocs.
Ini adalah merupakan directory sebagai localhost.

Buka browser dan type kan alamat berikut http://localhost/info.php

Selesai untuk permulaan..


-----------------------------------------------------------------------------------------------------

Info :-
K-REX.ORG

Sharing Is Caring ~ slashno1.gif
ABIGOROTH
nice topic

tapi kalau gune XAAMP oneclick install, SIAP!
dalam tu ada control panel utk apache mysql & ada bnyk lg function
mysql manager dia ialah phpmyadmin.

topic moved to tech talk when entertainment is not suitable for it. rgrds
-akob
Kenshiin Humura
Tkpe2, btw THX ~
slashlv.gif
ABIGOROTH
welcome 1.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.