By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,854 Members | 2,004 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,854 IT Pros & Developers. It's quick & easy.

how to make a new database?

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.