Install script problems

Codes here !

Moderators: macek, egami, gesf

Pezzoni
New php-forum User
New php-forum User
Posts: 4
Joined: Fri Jun 27, 2003 10:05 am

Install script problems

Postby Pezzoni » Fri Jun 27, 2003 10:07 am

Hi,
I'm currently writing an install script for the forum software I'm making, and I am having unbelieveably problems getting it to work.
As far as I, 1 professional coder, and 2 friends can see, the code it completely perfect, but it doesn't work.
Currently I'm getting this error:

Code: Select all

Parse error: parse error, unexpected $ in d:\program files\easyphp\www\forum\install\do_install.php on line 44


These are the files used for the install:

install.php:

Code: Select all

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<div align="center">
  <FORM ACTION="do_install.php" METHOD="POST">
    <table width="40%" border="1" cellspacing="0" bordercolor="#000000">
      <!--DWLayoutTable-->
      <tr>
        <td colspan="2" bgcolor="#000066"><div align="center"><font color="#FFFFFF" size="2" face="Verdana">General</font></div></td>
      </tr>
      <tr>
        <td width="174"><font size="2" face="Verdana">Database Host</font></td>
        <td width="182"><font size="2" face="Verdana">
          <INPUT TYPE="text" NAME="dbhost" VALUE="" MAXLENGTH="50">
          </font></td>
      </tr>
      <tr>
        <td><font size="2" face="Verdana">DB Name</font></td>
        <td><font size="2" face="Verdana">
          <INPUT TYPE="text" NAME="dbdatabase" VALUE="" MAXLENGTH="50">
          </font></td>
      </tr>
      <tr>
        <td><font size="2" face="Verdana">DB User</font></td>
        <td><font size="2" face="Verdana">
          <INPUT TYPE="text" NAME="dbuser" VALUE="" MAXLENGTH="50">
          </font></td>
      </tr>
      <tr>
        <td><font size="2" face="Verdana">DB Password</font></td>
        <td><font size="2" face="Verdana">
          <INPUT TYPE="password" NAME="dbpassword" VALUE="" MAXLENGTH="50">
          </font></td>
      </tr>
      <tr>
        <td height="28" colspan="2" valign="top"><div align="center">
            <input type="submit" name="install" value="Install DDbb">
          </div></td>
      </tr>
    </table>
  </FORM>
</div>
</body>
</html>



do_install.php:

Code: Select all

<?php
$DBDriver = $DBHost = $DBDatabase = $DBUser = $DBPass =  "";

$DBDriver       = "mysql";                    // DATABASE BEING USED (MYSQL SUPPORT ONLY)
$DBHost         = $_POST['dbhost'];           // "server" OR "server:port"
$DBDatabase     = $_POST['dbdatabase'];       // DATABASE NAME
$DBUser         = $_POST['dbuser'];           // USERNAME
$DBPass         = $_POST['dbpassword'];       // PASSWORD (CANNOT BE SEEN OUTSIDE THIS SCRIPT)


// *** ERROR CHECK 1 - DATABASE CONFIG OPTIONS
If (!eregi("^mysql$",$DBDriver)) {
   header("Location: install.php?error=1");
   exit;
}

If ($configfile = fopen("../config_file.php","w")) {
   $filecontent = <<<EOF_MARKER
<?php
/********************
 *DDbb Config File  *
 ********************/

/***********************
 DATABASE CONFIGURATION
 ***********************/
\$DBDriver   = "$DBDriver";                    // DATABASE BEING USED (MYSQL SUPPORT ONLY)
\$DBHost     = "$DBHost";                // "server" OR "server:port"
\$DBDatabase = "$DBDatabase";              // DATABASE NAME
\$DBUser     = "$DBUser";              // USERNAME
\$DBPass     = "$DBPass";                  // PASSWORD (CANNOT BE SEEN OUTSIDE THIS SCRIPT)
?>
EOF_MARKER;

   fputs($configfile,$filecontent);
   fclose($configfile);
} Else {
   header("Location: install.php?error=3");
   exit;
}

header("Location: create_database.php");
exit;
?>


create_databse.php:

Code: Select all

<?php

require_once("../config_file.php");
require_once("../functions.php");

db_Connect();
 
db_Query("CREATE TABLE posts (
   ID int(5) DEFAULT '0' NOT NULL auto_increment,
   TopicID int(5) DEFAULT '0' NOT NULL,
   Name varchar(50) NOT NULL,
   Email varchar(50) NOT NULL,
   Password varchar(50) NOT NULL,
   TimeStamp varchar(10) NOT NULL,
   Post text NOT NULL,
   PRIMARY KEY (ID)
)  TYPE=MyISAM",1);
db_Query("CREATE TABLE topics (
   ID int(5) DEFAULT '0' NOT NULL auto_increment,
   TopicName varchar(50) NOT NULL,
   PRIMARY KEY (ID)
)  TYPE=MyISAM",1);

exit;
?>


Many thanks to anyone who can help, this is driving me mad!

Dan

User avatar
Redcircle
Moderator
Moderator
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA
Contact:

Postby Redcircle » Fri Jun 27, 2003 10:10 pm

Hi,
I'm currently writing an install script for the forum software I'm making, and I am having unbelieveably problems getting it to work.
As far as I, 1 professional coder, and 2 friends can see, the code it completely perfect, but it doesn't work.
Currently I'm getting this error:


Tested the code on my server got no errors.

User avatar
bezmond
Moderator
Moderator
Posts: 312
Joined: Sat Apr 05, 2003 4:33 am
Location: Mansfield, UK
Contact:

Postby bezmond » Fri Jun 27, 2003 11:21 pm

Code: Select all

Code:
Parse error: parse error, unexpected $ in d:\program files\easyphp\www\forum\install\do_install.php on line 44

That unexpected $ means you are missing a } somewhere in your script...

Andrew

User avatar
bezmond
Moderator
Moderator
Posts: 312
Joined: Sat Apr 05, 2003 4:33 am
Location: Mansfield, UK
Contact:

Postby bezmond » Fri Jun 27, 2003 11:23 pm

one error I spotted though...

If ($configfile = fopen("../config_file.php","w")) {
$filecontent = <<<EOF_MARKER
<?php
/********************
*DDbb Config File *
********************/

why do you open PHP again without closing it?

Pezzoni
New php-forum User
New php-forum User
Posts: 4
Joined: Fri Jun 27, 2003 10:05 am

Postby Pezzoni » Sat Jun 28, 2003 12:58 am

Php is opened twice, and closed twice in the script.
The first time, it is to make this script work, and between the EOF Markers, it is so that the tags appear in the config file that this should generate.

Any ideas?
Or can anyone spot the missing bracket? :P

This could become a competition.
The first person to find it, wins a Virtual sticker.

Thanks,

Dan


Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 1 guest

cron