Page 1 of 1

Parse Error

Posted: Sun Sep 27, 2009 12:27 pm
by Christal
I'm getting "Parse error: syntax error, unexpected '}' in /home/capitalp/public_html/train/installer.php on line 84" in the following.

Code: Select all

<?php
if (!isset($_POST['submit'])) {
?>
<html>
<b>Train Installation</b><br><br>
Make sure you perform the following before running this installer:
<ul>
<li>CHMOD config.php to 0777</li>
</ul><br>
<form name="install" method="post" action="installer.php"><br>
MySQL Server: <input type="text" name="dbserver" value="localhost"><br>
MySQL Database: <input type="text" name="dbname"><br>
MySQL Usename: <input type="text" name="dbuser"><br>
MySQL Password: <input type="text" name="dbpass"><br>
Admin CP Password: <input type="text" name="admincp"><br>
<input type="submit" name="submit" value="Install Script">
</form>
</html>
<?php
}
else
{
if (!is_writable("config.php")) {
 echo "<B>The config.php is not writable (CHMOD to 0777)</B>";
 exit;
}
if (!is_readable("mysql.sql")) {
 echo "<b>The mysql.sql file cannot be read!  Check permission settings</B>";
 exit;
}
if (!is_readable("config_class.txt")) {
 echo "<B>Config_class.txt cannot be read!  Check permission settings</B>";
 exit;
}
}
$file = file_get_contents("config_class.txt");
$f = fopen("config.php","w");
$str = '<?
';
$str = $str.'$mysql["server"] = "'.$_POST["dbserver"].'";
';
$str = $str.'$mysql["user"] = "'.$_POST["dbuser"].'";
';
$str = $str.'$mysql["pass"] = "'.$_POST["dbpass"].'";
';
$str = $str.'$mysql["db"] = "'.$_POST['dbname'].'";
';
$str = $str.'$admin_pass = "'.$_POST['admincp'].'";
';
$str = $str.$file;
$str = $str.'
?>';
if (fwrite($f,$str)) {
 echo "Config file updated...<br>";
}
else
{
 echo "<B>Error - Unable to write to config file!</B>";
 exit;
}
fclose($f);
 
if (!mysql_connect($_POST['dbserver'],$_POST['dbuser'],$_POST['dbpass'])) {
 echo "MySQL connection failed - check inputted settings";
 exit;
}
if (!mysql_select_db($_POST['dbname'])) {
 echo "Unable to select MySQL Database!";
 exit;
}
$file = file_get_contents("mysql.sql");
 
$file = str_replace("'", "\'", $file);
 
$lines = explode(";", $file);
 
foreach ($lines as $line) {
 
    if (trim($line)!="") {
 
        $line = str_replace("%time%", time(), $line);
 
        mysql_query($line) or die("<b>".$line." - ".mysql_error()."</b>");
 
    }
 
}
?>
MySQL database setup...<br>
<font color="green"><b>Installation Complete!</b></font><br><br>
<font color="red"><B>IMPORTANT:</B></font> DELETE THIS INSTALLER.PHP & CONFIG_CLASS.TXT FILEs IF SITE IS INSTALLED CORECTLY!
Curly brackets seem to be matched and line 84 is blank, so I'm stuck. Any suggestions?

Re: Parse Error

Posted: Sun Sep 27, 2009 9:11 pm
by Ollie Saunders
Well, I got this:

Code: Select all

$ php -l tmp.php 
No syntax errors detected in tmp.php

Re: Parse Error

Posted: Mon Sep 28, 2009 1:33 am
by cpetercarter
"Unexpected '}' in....." often means that you forgot to end the previous line of code with a semi-colon.

Having said that, I can't see an error in the code in your posting. Perhaps you are actually running an earlier version of the script. Or maybe your browser is caching an earlier version of the webpage.

Re: Parse Error

Posted: Mon Sep 28, 2009 4:20 am
by Ollie Saunders
Having said that, I can't see an error in the code in your posting.
No, need to rely on what can be seen; I proved there is no syntax error in what was posted.