467,134 Members | 1,033 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,134 developers. It's quick & easy.

how to make a new database?

I want to make a new database with several tables, so I did the following:

<?php
CREATE DATABASE bedrijf;
CREATE TABLE werknemers
(voornaam varchar(15),
achternaam varchar(20),
leeftijd tinyint(3),
adres varchar(30),
woonplaats varchar(20),
land varchar(20));
?>

What is wrong with this, and do you know another way to make a new database?
Is there a site that explains all about myadmin?
Thanking you in advance,
Ruben.
Jul 16 '05 #1
  • viewed: 3052
Share:
2 Replies
uws
I <3f***********************@news.xs4all.nl>, Frans Schmidt skrev:
I want to make a new database with several tables, so I did the following:
<?php
CREATE DATABASE bedrijf;
?>
What is wrong with this, and do you know another way to make a new database?
You are writing SQL, not PHP. You will need to connect to a mysql server
first, and then execute the DDL queries.

Ruben.


Ruben or Frans? :s
mvrgr, Wouter

--
uws mail uw*@xs4all.nl

you're the mixed up girl that everybody leaves behind -- our lady peace
Jul 16 '05 #2
Frans Schmidt wrote:
I want to make a new database with several tables, so I did the following:

<?php
CREATE DATABASE bedrijf;
CREATE TABLE werknemers
(voornaam varchar(15),
achternaam varchar(20),
leeftijd tinyint(3),
adres varchar(30),
woonplaats varchar(20),
land varchar(20));
?>

What is wrong with this, and do you know another way to make a new database?
Is there a site that explains all about myadmin?
Thanking you in advance,
Ruben.

You can start by telling php what server the database is on. What kind
of database this is, and what username and password to use to loginto
the database. aka RTFM.

//create a link and loginto a mysql database
$dblink = mysql_connect(serveraddress, username, password);
//define our query to said server
$Query0 = "CREATE DATABASE bedrijf";
$Query1 = "CREATE TABLE werknemers"
"(voornaam varchar(15),".
"achternaam varchar(20)," .
"leeftijd tinyint(3)," .
"adres varchar(30)," .
"woonplaats varchar(20)," .
"land varchar(20))";

//make our query.
$dbresult = mysql_query($Query0, $dblink);
$dbresult = mysql_query($Query1, $dblink);

There is a _very_ small amount of things to read that will enable you to
do this properly, but you should do so.

Jul 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by WindAndWaves | last post: by
reply views Thread by Federico Moschini [328594] | last post: by
reply views Thread by anuradha.k.r@sify.com | last post: by
3 posts views Thread by LurfysMa | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.