묻고답하기
page_full_width" class="col-xs-12" |cond="$__Context->page_full_width">
쿼리문을 저장하고 보낼 때에 관련하여 질문입니다.
2004.08.23 17:38
지금 APM을 사용하여 php를 공부하고 있습니다. 다음과 같은 쿼리를 저장하고 DB에 보내려 하는데 제가 초보여서 막히네요.
다음은 DB에 보내고자한 쿼리문입니다. 참고로 phpMyadmin을 사용하면 이상없이 아주 잘됩니다.
create table customers
( customerid int unsigned not null auto_increment primary key,
name char(30) not null,
address char(40) not null,
city char(20) not null
);
create table orders
( orderid int unsigned not null auto_increment primary key,
customerid int unsigned not null,
amount float(6,2),
date date not null
);
create table books
( isbn char(13) not null primary key,
author char(30),
title char(60),
price float(4,2)
);
create table order_items
( orderid int unsigned not null,
isbn char(13) not null,
quantity tinyint unsigned,
primary key (orderid, isbn)
);
create table book_reviews
(
isbn char(13) not null primary key,
review text
);
-------------------------------------------------------------------------------------------------------
<?
include "connect.php";
$query="
create table customers
( customerid int unsigned not null auto_increment primary key,
name char(30) not null,
address char(40) not null,
city char(20) not null
);
create table orders
( orderid int unsigned not null auto_increment primary key,
customerid int unsigned not null,
amount float(6,2),
date date not null
);
create table books
( isbn char(13) not null primary key,
author char(30),
title char(60),
price float(4,2)
);
create table order_items
( orderid int unsigned not null,
isbn char(13) not null,
quantity tinyint unsigned,
primary key (orderid, isbn)
);
create table book_reviews
(
isbn char(13) not null primary key,
review text
)";
mysql_query ($query,$connect);
?>
이런 식으로 쿼리문을 작성해서 DB에 보내봤지만 역시나 에러가 나더군요. 어떻게 바꿔야 에러없이 잘 될까요?
다음은 DB에 보내고자한 쿼리문입니다. 참고로 phpMyadmin을 사용하면 이상없이 아주 잘됩니다.
create table customers
( customerid int unsigned not null auto_increment primary key,
name char(30) not null,
address char(40) not null,
city char(20) not null
);
create table orders
( orderid int unsigned not null auto_increment primary key,
customerid int unsigned not null,
amount float(6,2),
date date not null
);
create table books
( isbn char(13) not null primary key,
author char(30),
title char(60),
price float(4,2)
);
create table order_items
( orderid int unsigned not null,
isbn char(13) not null,
quantity tinyint unsigned,
primary key (orderid, isbn)
);
create table book_reviews
(
isbn char(13) not null primary key,
review text
);
-------------------------------------------------------------------------------------------------------
<?
include "connect.php";
$query="
create table customers
( customerid int unsigned not null auto_increment primary key,
name char(30) not null,
address char(40) not null,
city char(20) not null
);
create table orders
( orderid int unsigned not null auto_increment primary key,
customerid int unsigned not null,
amount float(6,2),
date date not null
);
create table books
( isbn char(13) not null primary key,
author char(30),
title char(60),
price float(4,2)
);
create table order_items
( orderid int unsigned not null,
isbn char(13) not null,
quantity tinyint unsigned,
primary key (orderid, isbn)
);
create table book_reviews
(
isbn char(13) not null primary key,
review text
)";
mysql_query ($query,$connect);
?>
이런 식으로 쿼리문을 작성해서 DB에 보내봤지만 역시나 에러가 나더군요. 어떻게 바꿔야 에러없이 잘 될까요?