how to make a new database?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Frans Schmidt

    #1

    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.


  • uws

    #2
    Re: how to make a new database?

    I <3f05752e$0$491 16$e4fe514c@new s.xs4all.nl>, Frans Schmidt skrev:[color=blue]
    > 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?[/color]

    You are writing SQL, not PHP. You will need to connect to a mysql server
    first, and then execute the DDL queries.

    [color=blue]
    > Ruben.[/color]

    Ruben or Frans? :s


    mvrgr, Wouter

    --
    uws mail uws@xs4all.nl

    you're the mixed up girl that everybody leaves behind -- our lady peace

    Comment

    • Korthrun McBloodlust

      #3
      Re: how to make a new database?

      Frans Schmidt wrote:
      [color=blue]
      > 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.
      >
      >[/color]
      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(s erveraddress, 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($Qu ery0, $dblink);
      $dbresult = mysql_query($Qu ery1, $dblink);



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

      Comment

      Working...