Jump to content

$end error That I think is caused by fopen


big-dog1965

Recommended Posts

Can someone spot my problem here I had it to where it created tables and inserted data into some tables I thought since the create and insert was getting so big I would open a .sql file and do it that way so I took out the create and insert stuff and replaced it with what’s at ******** Now I get this error

Parse error: syntax error, unexpected $end in /home5/wichitar/public_html/ClanApp/Administration/setup.php on line 164 this is the very last line

I tend to think it something to do with what I added because it installed my tables and everything before I changed it to ***** area.

 

<?php


if(is_array($_POST)){
$HTTP_POST_VARS=$_POST;
}
if(is_array($_GET)){
$HTTP_GET_VARS=$_GET;
}

include(dirname(__FILE__)."/language.php");

$divFormat="<div style=\"text-align: center; font-weight: bold; font-family: verdana,arial; font-size: 15px;\">";
$backHome="$divFormat<a href=\"./\">".$Translation["goto start page"]."</a></div>";

// check this file's MD5 to make sure it wasn't called before
$prevMD5=@implode('', @file("./setup.md5"));
$thisMD5=md5(@implode('', @file("./setup.php")));
if($thisMD5==$prevMD5){
	echo "$divFormat ".$Translation["setup performed"]." ".date("r", filemtime("./setup.md5")).".<br><br></div>";
	echo "$divFormat<div style=\"font-size: 10px;\">".$Translation["delete md5"]."</div></div><br><br>";
	echo $backHome;
	exit;
}

// connect to the database
$dbServer=$HTTP_POST_VARS['dbServer'];
$dbUsername=$HTTP_POST_VARS['dbUsername'];
$dbPassword=$HTTP_POST_VARS['dbPassword'];
$dbDatabase=$HTTP_POST_VARS['dbDatabase'];
$noDB=0;
if(!@mysql_connect($dbServer, $dbUsername, $dbPassword)){
	$noDB=1;
}elseif(!@mysql_select_db($dbDatabase)){
	if(!@mysql_query("create database `$dbDatabase`")){
		$noDB=2;
	}else{
		if(!@mysql_select_db($dbDatabase)){
			$noDB=2;
		}
	}
}

// if no connection established, ask for connection data
if($noDB){
	if($dbServer!=''){
		echo $divFormat."<div style=\"color: red;\">".($noDB==1 ? $Translation["no db connection"] : str_replace("<DBName>", $dbDatabase, $Translation["no db name"]))."</div>"."</div>";
	}

?>
	<form method="post" action="setupORG.php">
		<?php echo $divFormat; ?>
			<?php echo $Translation["provide connection data"]; ?>
			<center>
			<table bgcolor="#BFD5FF" style="border: solid silver 1px;" width="56%">
				<tr>
					<td align="right" width="35%"><?php echo $divFormat; ?><?php echo $Translation["mysql server"]; ?></div></td>
					<td>
					<input type="text" name="dbServer" size="20" value="localhost"></td>
					</tr>
				<tr>
					<td align="right" width="35%"><?php echo $divFormat; ?><?php echo $Translation["mysql username"]; ?></div></td>
					<td><input type="text" name="dbUsername" size="10"></td>
					</tr>
				<tr>
					<td align="right" width="35%"><?php echo $divFormat; ?><?php echo $Translation["mysql password"]; ?></div></td>
					<td><input type="password" name="dbPassword" size="10"></td>
					</tr>
				<tr>
					<td align="right" width="35%"><?php echo $divFormat; ?><?php echo $Translation["mysql db"]; ?></div></td>
					<td>
					<input type="text" name="dbDatabase" size="15" value="_ClanApplications"></td>
					</tr>
				<tr>
					<td align="right" width="35%"></td>
					<td><input type="submit" value="<?php echo $Translation["connect"]; ?>">
					</td>
					</tr>
				</table>
				</center>
		<p align="center">Delete this file through ftp after setup is complete 
		(setup.php)<br></p>
		<div style="font-size: 10px;"></div>
			</div>
		</form>
<?php
	exit;
}else{
	// if connection is successful, save parameters into config.php
	if(!$fp=@fopen("./config.php", "w")){
		echo $divFormat."<div style=\"color: red;\">".$Translation["couldnt save config"]."</div></div><br>";
		echo $backHome;
		exit;
	}else{
		fwrite($fp, "<?php\n");
		fwrite($fp, "\t\$dbServer=\"$dbServer\";\n");
		fwrite($fp, "\t\$dbUsername=\"$dbUsername\";\n");
		fwrite($fp, "\t\$dbPassword=\"$dbPassword\";\n");
		fwrite($fp, "\t\$dbDatabase=\"$dbDatabase\";\n");
		fwrite($fp, "?>");
		fclose($fp);

	}
}
*************	
$f = fopen('DataBase_Tables.sql','r');
while($t = fread($f,1024657)){ $sql .= $t;}
fclose($f);
$lines = explode(';',$sql);
foreach($lines as $line){
	if(trim($line)){
		mysql_query($line) or die(mysql_error());
	}
*************************	
// save MD5
if($fp=@fopen("./setup.md5", "w")){
	fwrite($fp, $thisMD5);
	fclose($fp);
}

// go to index
echo $backHome;

// ------------------------------------------

function setupTable($tableName, $createSQL='', $arrAlter=''){
	global $Translation;

	echo "<div style=\"padding: 5px; border-bottom:solid 1px silver; font-family: verdana, arial; font-size: 10px;\">";
	if($res=@mysql_query("select count(1) from `$tableName`")){
		if($row=@mysql_fetch_array($res)){
			echo str_replace("<TableName>", $tableName, str_replace("<NumRecords>", $row[0],$Translation["table exists"]));
			if(is_array($arrAlter)){
				echo '<br>';
				foreach($arrAlter as $alter){
					if($alter!=''){
						echo "$alter ... ";
						if(!@mysql_query($alter)){
							echo "<font color=red>".$Translation["failed"]."</font><br>";
							echo "<font color=red>".$Translation["mysql said"]." ".mysql_error()."</font><br>";
						}else{
							echo "<font color=green>".$Translation["ok"]."</font><br>";
						}
					}
				}
			}else{
				echo $Translation["table uptodate"];
			}
		}else{
			echo str_replace("<TableName>", $tableName, $Translation["couldnt count"]);
		}
	}else{
		echo str_replace("<TableName>", $tableName, $Translation["creating table"]);
		if(!@mysql_query($createSQL)){
			echo "<font color=red>".$Translation["failed"]."</font><br>";
			echo "<font color=red>".$Translation["mysql said"].mysql_error()."</font>";
		}else{
			echo "<font color=green>".$Translation["ok"]."</font>";
		}
	}

	echo "</div>";
}
?>**********

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.