Announcement

Collapse
No announcement yet.

my install script problem (arrays)

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

  • my install script problem (arrays)

    Can anyone help me with this please?, it may look very basic but I am just learning. Thanks for your time

    Code:
    
    
    <?php
    /***************************************************************************
    *                           install.php  -  description
    *                              -------------------
    *     begin                : Sat January 06 2000
    *     copyright            : (C)2000 by Darren McCabe
    *     email                : [email protected]
    *     $Id                  : install.php,v 1.00 06/1/2000 09:20:23
    * 
    ****************************************************************************/
    
    
    // hostname or ip of server
    $servername="localhost";
    
    // username and password to log onto db server
    $dbusername="root";
    
    // admin database password
    $dbpassword="################";
    
    // name of database
    $dbname="userdata";
    
    
    ?>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">
    <HTML>
    <HEAD>
    <TITLE>Database Setup - Installation</TITLE>
    </HEAD>
    <BODY BGCOLOR="#000000" TEXT="#FFFFFF" LINK="#11C6BD" VLINK="#11C6BD">
    
    <?php
    
         
    // ################### create mysql database ####################
    
    
    echo "Testing DB Connection...";
    	 flush();
    	 if(!$db = mysql_connect("$servername", "$dbusername", "$dbpassword"))
    	   die("<font color=\"#FF0000\">Error, I could not connect to the database at $dbserver. Using username $dbuser and password $dbpass.<BR>Please go back and try again.");
    	 echo "<font color=\"#00FF00\">DB Connection Good!</FONT><BR>";
    	 flush();
    	 echo "Selected database $dbname...";
    	 flush();
    	 if([email protected]_select_db("$dbname", $db)) 
              {
    	    echo "<font color=\"#FF0000\">Database could not be found</font><BR>";
    	    flush();
    	    echo "Attempting to create database $dbname...";
    	    flush();
    	    if(!$r = mysql_query("CREATE DATABASE $dbname", $db))
    	      die("<font color=\"#FF0000\">Error, count not select or create database $dbname, please create it manually or have your system administrator do it for you and try again.");
    	    mysql_select_db("$dbname", $db);
    	    echo "<font color=\"#00FF00\">Database Created!</font><BR>";
    	    flush();
              }
    	 else
    	   echo "<font color=\"#00FF00\">Database Selected!</font><BR>";
    	 flush();
    	 echo "Creating tables and inserting default data...<BR>";
    	 flush();
    
    
    // ###################### setup users table #######################
    
    
    $table1 = array ("profiles" => "CREATE TABLE profiles (
    
       
       userid INT UNSIGNED NOT NULL AUTO_INCREMENT,
       usergroupid SMALLINT UNSIGNED NOT NULL,
       username CHAR(50) NOT NULL,
       password CHAR(50) NOT NULL,
       email CHAR(50) NOT NULL,
       parentemail CHAR(50) NOT NULL,
       coppauser SMALLINT NOT NULL,
       homepage CHAR(100) NOT NULL,
       icq CHAR(20) NOT NULL,
       aim CHAR(20) NOT NULL,
       yahoo CHAR(20) NOT NULL,
       biography MEDIUMTEXT NOT NULL,
       signature MEDIUMTEXT NOT NULL,
       adminemail SMALLINT NOT NULL,
       showemail SMALLINT NOT NULL,
       invisible SMALLINT NOT NULL,
       usertitle CHAR(250) NOT NULL,
       customtitle SMALLINT NOT NULL,
       joindate INT UNSIGNED NOT NULL,
       canpost SMALLINT NOT NULL,
       cookieuser SMALLINT NOT NULL,
       daysprune SMALLINT NOT NULL,
       lastvisit INT UNSIGNED NOT NULL,
       lastactivity INT UNSIGNED NOT NULL,
       lastpost INT UNSIGNED NOT NULL,
       posts SMALLINT UNSIGNED NOT NULL,
       timezoneoffset SMALLINT NOT NULL,
       emailnotification SMALLINT NOT NULL,
    
    PRIMARY KEY (user_id)      
    INDEX idxgroups(username,password,usergroupid)
     )",
    
    
    
      // ###################### Start usergroup #######################
    
      ("usergroup" => "CREATE TABLE usergroup ( 
    
       usergroupid SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
       title CHAR(100) NOT NULL,
       usertitle CHAR(100) NOT NULL,
       canview SMALLINT NOT NULL,
       cansearch SMALLINT NOT NULL,
       canemail SMALLINT NOT NULL,
       canpostnew SMALLINT NOT NULL,
       canreply SMALLINT NOT NULL,
       canadminedit SMALLINT NOT NULL,
       canedit SMALLINT NOT NULL,
       candelete SMALLINT NOT NULL,
       canopenclose SMALLINT NOT NULL,
       canmove SMALLINT NOT NULL,
       cancontrolpanel SMALLINT NOT NULL,
       PRIMARY KEY(usergroupid)
      )");
    
    
    "userstatus" =>  "CREATE TABLE userstatus (
    
    $userstatus_data = array("
    "INSERT INTO usergroup VALUES (1,'Unregistered / Not Logged In','Guest',1,1,1,0,0,0,0,0,0,0,0)");
    "INSERT INTO usergroup VALUES (2,'Registered','',1,1,1,1,1,0,1,1,1,0,0)");
    "INSERT INTO usergroup VALUES (3,'Users Awaiting Email Confirmation','',1,1,1,0,0,0,0,0,0,0,0)");
    "INSERT INTO usergroup VALUES (4,'(COPPA) Users Awaiting Moderation','',1,1,1,0,0,0,0,0,0,0,0)");
    "INSERT INTO usergroup VALUES (5,'Super Moderator','Super Moderator',1,1,1,1,1,1,1,1,1,1,0)");
    "INSERT INTO usergroup VALUES (6,'Administrator','Administrator',1,1,1,1,1,1,1,1,1,1,1)");
    )",
    
    echo "succeeded</p>";
    
    
    
    
    ?>
    I get the following error

    Testing DB Connection...DB Connection Good!
    Selected database userdata...Database Selected!
    Creating tables and inserting default data...

    Parse error: parse error in /home/httpd/html/install.php on line 114

    which is near the ("usergroup" => "CREATE TABLE usergroup (

    It creates the database but no tables or data in them

    [Edited by the_net_muppet on 01-06-2001 at 03:04 PM]

  • #2
    You seem to mix up a comma and semi-colon And some of your parentheses didn't seem to match.

    Code:
    $table1 = array (
       "profiles" 
          => 
       "CREATE TABLE profiles (  
          userid INT UNSIGNED NOT NULL AUTO_INCREMENT,
          usergroupid SMALLINT UNSIGNED NOT NULL,
          username CHAR(50) NOT NULL,
          password CHAR(50) NOT NULL,
          email CHAR(50) NOT NULL,
          parentemail CHAR(50) NOT NULL,
          coppauser SMALLINT NOT NULL,
          homepage CHAR(100) NOT NULL,
          icq CHAR(20) NOT NULL,
          aim CHAR(20) NOT NULL,
          yahoo CHAR(20) NOT NULL,
          biography MEDIUMTEXT NOT NULL,
          signature MEDIUMTEXT NOT NULL,
          adminemail SMALLINT NOT NULL,
          showemail SMALLINT NOT NULL,
          invisible SMALLINT NOT NULL,
          usertitle CHAR(250) NOT NULL,
          customtitle SMALLINT NOT NULL,
          joindate INT UNSIGNED NOT NULL,
          canpost SMALLINT NOT NULL,
          cookieuser SMALLINT NOT NULL,
          daysprune SMALLINT NOT NULL,
          lastvisit INT UNSIGNED NOT NULL,
          lastactivity INT UNSIGNED NOT NULL,
          lastpost INT UNSIGNED NOT NULL,
          posts SMALLINT UNSIGNED NOT NULL,
          timezoneoffset SMALLINT NOT NULL,
          emailnotification SMALLINT NOT NULL,
          PRIMARY KEY (user_id)      
          INDEX idxgroups(username,password,usergroupid)
       )",
    
    // ###################### Start usergroup #######################
    
       "usergroup" 
          => 
       "CREATE TABLE usergroup ( 
          usergroupid SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
          title CHAR(100) NOT NULL,
          usertitle CHAR(100) NOT NULL,
          canview SMALLINT NOT NULL,
          cansearch SMALLINT NOT NULL,
          canemail SMALLINT NOT NULL,
          canpostnew SMALLINT NOT NULL,
          canreply SMALLINT NOT NULL,
          canadminedit SMALLINT NOT NULL,
          canedit SMALLINT NOT NULL,
          candelete SMALLINT NOT NULL,
          canopenclose SMALLINT NOT NULL,
          canmove SMALLINT NOT NULL,
          cancontrolpanel SMALLINT NOT NULL,
          PRIMARY KEY(usergroupid)
       )"; // End array
    
    /** Not finished
    "userstatus" =>  "CREATE TABLE userstatus (...)"
    **/
    
    
    $userstatus_data = array(
       "INSERT INTO usergroup VALUES (1,'Unregistered / Not Logged In','Guest',1,1,1,0,0,0,0,0,0,0,0)",
       "INSERT INTO usergroup VALUES (2,'Registered','',1,1,1,1,1,0,1,1,1,0,0)",
       "INSERT INTO usergroup VALUES (3,'Users Awaiting Email Confirmation','',1,1,1,0,0,0,0,0,0,0,0)",
       "INSERT INTO usergroup VALUES (4,'(COPPA) Users Awaiting Moderation','',1,1,1,0,0,0,0,0,0,0,0)",
       "INSERT INTO usergroup VALUES (5,'Super Moderator','Super Moderator',1,1,1,1,1,1,1,1,1,1,0)",
       "INSERT INTO usergroup VALUES (6,'Administrator','Administrator',1,1,1,1,1,1,1,1,1,1,1)",
    )";

    Comment


    • #3
      Whoo whoo! thanks Ed, I will check it out later

      Comment

      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
      Working...
      X