php ù»ç¶û¿¬µ¿Çϱâ,
MYSQL+php ÇÔ²² ¿¬µ¿Çϱâ ÀԷ°úÃâ·ÂÇϱâ
:::MySQLÀÛ¾÷Çϱâ::::::::::::::::::::::::::::::::::: Microsoft Windows 2000 [Version 5.00.2195] (C) Copyright 1985-2000 Microsoft Corp.
C:\Documents and Settings\Administrator>mysql ERROR 1045: ODBC@localhost »ç¿ëÀÚ´Â Á¢±ÙÀÌ °ÅºÎ µÇ¾ú½À´Ï´Ù. (Using password: ¾Æ´Ï¿À)
C:\Documents and Settings\Administrator> C:\Documents and Settings\Administrator> C:\Documents and Settings\Administrator>mysql -u root -p mysql Enter password: ******** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 to server version: 4.0.21-nt
Type help; or \h for help. Type \c to clear the buffer.
mysql> create database appledb; Query OK, 1 row affected (0.13 sec)
mysql> grant all on appledb.* to apple@localhost identified by 1234; Query OK, 0 rows affected (0.16 sec)
mysql> exit Bye
C:\Documents and Settings\Administrator>mysql -u apple -p Enter password: **** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 to server version: 4.0.21-nt
Type help; or \h for help. Type \c to clear the buffer.
mysql> \s -------------- mysql Ver 12.22 Distrib 4.0.21, for Win95/Win98 (i32)
Connection id: 3 Current database: Current user: apple@localhost SSL: Not in use Server version: 4.0.21-nt Protocol version: 10 Connection: localhost via TCP/IP Client characterset: latin1 Server characterset: latin1 TCP port: 3306 Uptime: 48 min 7 sec
Threads: 1 Questions: 8 Slow queries: 0 Opens: 8 Flush tables: 1 Open tables: 2 Queries per second avg: 0.003 --------------
mysql> show databaes; ERROR 1064: SQL ±¸¹®¿¡ ¿À·ù°¡ ÀÖ½À´Ï´Ù. ¿¡·¯ °°À¾´Ï´Ù. (databaes ¸í·É¾î ¶óÀÎ 1) mysql> show databases; +----------+ | Database | +----------+ | appledb | +----------+ 1 row in set (0.00 sec)
mysql> use appledb; Database changed mysql> show tables; Empty set (0.00 sec)
mysql> mysql> create table mymemo(num int not null auto_increment primary key, -> name varchar(20) not null, -> email varchar(30) not null, -> memo varchar(100) not null); Query OK, 0 rows affected (0.06 sec)
mysql> mysql> memo varchar(100) not null); ERROR 1064: SQL ±¸¹®¿¡ ¿À·ù°¡ ÀÖ½À´Ï´Ù. ¿¡·¯ °°À¾´Ï´Ù. (memo varchar(100) not null) ¸í·É¾î ¶óÀÎ 1) mysql> mysql> select * from mymemo; +-----+------+-------+------+ | num | name | email | memo | +-----+------+-------+------+ | 1 | 22 | 22 | 22 | +-----+------+-------+------+ 1 row in set (0.02 sec)
mysql>
:::memoinput.html::::::::::::::::::::::::::::::::::: <!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN> <HTML> <HEAD> <TITLE> New Document </TITLE>
</HEAD>
<BODY> <br> <form method=post action=memoinput.php> <table border=1 width=500>
<tr> <td>À̸§</td> <td><input type=text name=name></td> </tr> <tr> <td>À̸ÞÀÏ</td> <td><input type=text name=email></td> </tr> <tr> <td>¸Þ¸ð</td> <td><input type=text name=memo size=50></td> </tr>
<tr> <td colspan=2 align=center> <input type=submit value=Àü¼Û> <input type=reset value=Ãë¼Ò> </td> </tr> </table> </form> </BODY> </HTML>
:::memoinput.php::::::::::::::::::::::::::::::: <? echo ³Ñ¾î¿ÂÀ̸§ --- $name<br>; echo ³Ñ¾î¿Â¸ÞÀÏ --- $email<br>; echo ³Ñ¾î¿Â¸Þ¸ð --- $memo<br>; $connect=mysql_connect(localhost,apple,1234); $db=mysql_select_db(appledb,$connect);
$query=insert into mymemo values(NULL,$name,$email,$memo);
$result=mysql_query($query,$connect);
if($result){ echo µ¥ÀÌŸ ÀԷ¼º°ø!; }else { echo µ¥ÀÌŸ ÀԷ½ÇÆÐ!; } ?>
:::list_test.php:::::::::::::::::::::::::::::::::::::: <? include connect.php; $query=select * from mymemo; //$query=select name from mymemo;//À̸§°ª¸¸°¡Á®¿À±â
$result=mysql_query($query,$connect); $row=mysql_fetch_row($result); //echo $row[0] ---$row[1]---$row[2]---$row[3];//°¡·ÎÃâ·Â echo $row[0] <br>; echo $row[1] <br>; echo $row[2] <br>; //¼¼·ÎÃâ·Â
?> ----¹æ¹ý2------------------------------------------- <? include connect.php; $query=select * from mymemo; //$query=select name from mymemo;//À̸§°ª¸¸°¡Á®¿À±â
$result=mysql_query($query,$connect); //$row=mysql_fetch_row($result);//while¹®À¸·Î ÀÛ¾÷ÇÒ¶§´Â ÁÖ¼®(»ý·«) //echo $row[0] ---$row[1]---$row[2]---$row[3];//°¡·ÎÃâ·Â
//echo $row[0] <br>; //echo $row[1] <br>; //echo $row[2] <br>; //¼¼·ÎÃâ·Â while($row=mysql_fetch_row($reslt)){ echo $row[] } ?>
:::::::::::::::::::::::::::::::::::::::::: Å×½ºÆ®Çϱâ http://localhost/memoinput.php
PHP½ºÅ͵ð 2004 11 14
¼Ò½ºÁö¼¼È÷º¸±â
http://www.6VJ.com/php/php1124.txt
|