Web Analytics Made Easy -
StatCounter creating a table in MYSQL - CodingForum

Announcement

Collapse
No announcement yet.

creating a table in MYSQL

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • creating a table in MYSQL

    Ive done some php and have up till now used phpadmin to create tables, I dont have that feature now so have made this sql code to create a table:
    but what is the file type, sql.php? .sql?

    <?php

    include 'conn.php'

    CREATE TABLE phpbb_charts (
    chart_id mediumint(8) NOT NULL auto_increment,
    chart_song_name varchar(80) NOT NULL,
    chart_artist varchar(80) NOT NULL,
    chart_album varchar(80) default '',
    chart_poster_id varchar(80) NOT NULL,
    chart_hot mediumint(8) default '0',
    chart_not mediumint(8) default '0',
    chart_curr_pos mediumint(8) default '0',
    chart_last_pos mediumint(8) default '0',
    chart_best_pos mediumint(8) default '0',
    PRIMARY KEY (chart_id)
    ) TYPE=MyISAM;

    CREATE TABLE phpbb_charts_voters (
    vote_id mediumint(8) NOT NULL auto_increment,
    vote_user_id mediumint(8) NOT NULL,
    vote_chart_id mediumint(8) NOT NULL,
    vote_rate smallint(2) NOT NULL,
    PRIMARY KEY (vote_id),
    FOREIGN KEY (vote_chart_id) REFERENCES phpbb_charts(chart_id)
    ) TYPE=MyISAM;

    INSERT INTO phpbb_config VALUES('charts_week_num','1');

    ?>

    When I use .php this error occurs

    Parse error: parse error in home/fhlinux195/functionalsound.co.uk/user/htdocs/sql.php on line 4

    any help would be appreciated
    Jason Morjaria

  • #2
    Why don't you just install phpMyAdmin since that is what you are used to using? It is free.
    Spookster
    CodingForum Supreme Overlord
    All Hail Spookster

    Comment


    • #3
      PHP Code:
      <?php
      include 'conn.php'

      $sql1 "
      CREATE TABLE phpbb_charts (
      chart_id mediumint(8) NOT NULL auto_increment,
      chart_song_name varchar(80) NOT NULL,
      chart_artist varchar(80) NOT NULL,
      chart_album varchar(80) default '',
      chart_poster_id varchar(80) NOT NULL,
      chart_hot mediumint(8) default '0',
      chart_not mediumint(8) default '0',
      chart_curr_pos mediumint(8) default '0',
      chart_last_pos mediumint(8) default '0',
      chart_best_pos mediumint(8) default '0',
      PRIMARY KEY (chart_id)
      ) TYPE=MyISAM"
      ;

      mysql_query($sql1);

      $sql2 "CREATE TABLE phpbb_charts_voters (
      vote_id mediumint(8) NOT NULL auto_increment,
      vote_user_id mediumint(8) NOT NULL,
      vote_chart_id mediumint(8) NOT NULL,
      vote_rate smallint(2) NOT NULL,
      PRIMARY KEY (vote_id),
      FOREIGN KEY (vote_chart_id) REFERENCES phpbb_charts(chart_id)
      ) TYPE=MyISAM"
      ;

      mysql_query($sql2);

      $sql3 "INSERT INTO phpbb_config VALUES('charts_week_num','1')";

      mysql_query($sql3);
      ?>

      Comment


      • #4
        is it possible to have

        CREATE TABLE artists (
        ID ect.
        BandName varchar(80),

        )

        All the examples of SQL always have either NOT NULL or default at the end, what happens If I dont mind whether the user inputs these are not, what do I put then.
        Jason Morjaria

        Comment

        Working...
        X