this is my code,
<?php
include('Wizard.php');
class FieldMap extends Wizard{
public function getPageTitle(){
return "Map DB Fields";
}
public function index(){
$this->fieldMapping();
}
public function deleteMapping(){
if(is_file(PATH_DIR."dbMaps/".$_GET[dbID].".php")){
@unlink(PATH_DIR."dbMaps/".$_GET[dbID].".php");
}
$this->myDBObj->delete("databases" , "id = '$_GET[dbID]'");
echo $this->myDBObj->getLastError();
$this->myDBObj->delete("sites" , "dbid = '$_GET[dbID]'");
header("Location: .");
}
public function fieldMapping(){
if(count($_POST)){
$this->saveMap();
}
$fieldsData = array();
if(is_file(PATH_DIR."dbMaps/".$_GET[dbID].".php")){
include(PATH_DIR."dbMaps/".$_GET[dbID].".php");
}
$tableFields = array();
{
$tables = $this->dbObj->getTables();
foreach($tables as $table){
$tableFields[$table] = $this->dbObj->getFields($table);
}
$data[tableFields] = $tableFields;
$data[PKs] = $this->dbObj->getPKs();
$data[fieldsData] = $fieldsData;
$this->loadTemplate("FieldMap" , $data);
}
function saveMap(){
$tables = $this->dbObj->getTables();
foreach($tables as $table){
$fields = $this->dbObj->getFields($table);
foreach($fields as $field){
$_DATA['data']['tables'][$table]['fields'][] = $field;
$fldName = $table."_".$field[Field];
if($field["PK"]=="PRI"){
$_DATA['data']['tables'][$table]['primary'] = $field[Field];
}
if($_POST["fk_$fldName"] != ""){
$_DATA['data']['tables'][$table]['links'][$field[Field]] = $_POST["fk_$fldName"];
}
{
$fileContent = var_export($_DATA['data'] , true);
$fileContent = "<?\n\$fieldsData = $fileContent ; \n?>";
$fp = fopen(PATH_DIR."dbMaps/".$_GET[dbID].".php" , "w");
fwrite($fp , $fileContent);
fclose($fp);
header("Location: .");$this->funcPath("MainPage");
}
?>
this is my error message
Parse error: syntax error, unexpected $end in /home/j05ayrw/public_html/viz/Classes/Wizards/FieldMap.php on line 77
i got something wrong and thisd is driving me nuts. any suggestions most welcome!
help need with error
Moderator: General Moderators
Re: help need with error
Look at line 66, you have an opening bracket without a conditional statement.
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Re: help need with error
No, that's perfectly legal. Odd, but legal.Jade wrote:Look at line 66, you have an opening bracket without a conditional statement.
Line 77 is the end of the file. The error stating "unexpected end" means that the end came without warning. This is almost always the result of unmatched braces (though sometimes the result of unmatched quotation marks, HEREDOC syntax, parentheses, or braces). In order to fix it, try properly indenting your code.
What you have is this:
Code: Select all
<?php
include('Wizard.php');
class FieldMap extends Wizard{
public function getPageTitle(){
return "Map DB Fields";
}
public function index(){
$this->fieldMapping();
}
public function deleteMapping(){
if(is_file(PATH_DIR."dbMaps/".$_GET[dbID].".php")){
@unlink(PATH_DIR."dbMaps/".$_GET[dbID].".php");
}
$this->myDBObj->delete("databases" , "id = '$_GET[dbID]'");
echo $this->myDBObj->getLastError();
$this->myDBObj->delete("sites" , "dbid = '$_GET[dbID]'");
header("Location: .");
}
public function fieldMapping(){
if(count($_POST)){
$this->saveMap();
}
$fieldsData = array();
if(is_file(PATH_DIR."dbMaps/".$_GET[dbID].".php")){
include(PATH_DIR."dbMaps/".$_GET[dbID].".php");
}
$tableFields = array();
{
$tables = $this->dbObj->getTables();
foreach($tables as $table){
$tableFields[$table] = $this->dbObj->getFields($table);
}
$data[tableFields] = $tableFields;
$data[PKs] = $this->dbObj->getPKs();
$data[fieldsData] = $fieldsData;
$this->loadTemplate("FieldMap" , $data);
}
function saveMap(){
$tables = $this->dbObj->getTables();
foreach($tables as $table){
$fields = $this->dbObj->getFields($table);
foreach($fields as $field){
$_DATA['data']['tables'][$table]['fields'][] = $field;
$fldName = $table."_".$field[Field];
if($field["PK"]=="PRI"){
$_DATA['data']['tables'][$table]['primary'] = $field[Field];
}
if($_POST["fk_$fldName"] != ""){
$_DATA['data']['tables'][$table]['links'][$field[Field]] = $_POST["fk_$fldName"];
}
{
$fileContent = var_export($_DATA['data'] , true);
$fileContent = "<?\n\$fieldsData = $fileContent ; \n?>";
$fp = fopen(PATH_DIR."dbMaps/".$_GET[dbID].".php" , "w");
fwrite($fp , $fileContent);
fclose($fp);
header("Location: .");$this->funcPath("MainPage");
}
?>Code: Select all
<?php
include('Wizard.php');
class FieldMap extends Wizard{
public function getPageTitle(){
return "Map DB Fields";
}
public function index(){
$this->fieldMapping();
}
public function deleteMapping(){
if(is_file(PATH_DIR."dbMaps/".$_GET[dbID].".php")){
@unlink(PATH_DIR."dbMaps/".$_GET[dbID].".php");
}
$this->myDBObj->delete("databases" , "id = '$_GET[dbID]'");
echo $this->myDBObj->getLastError();
$this->myDBObj->delete("sites" , "dbid = '$_GET[dbID]'");
header("Location: .");
}
public function fieldMapping(){
if(count($_POST)){
$this->saveMap();
}
$fieldsData = array();
if(is_file(PATH_DIR."dbMaps/".$_GET[dbID].".php")){
include(PATH_DIR."dbMaps/".$_GET[dbID].".php");
}
$tableFields = array();
{
$tables = $this->dbObj->getTables();
foreach($tables as $table){
$tableFields[$table] = $this->dbObj->getFields($table);
}
$data[tableFields] = $tableFields;
$data[PKs] = $this->dbObj->getPKs();
$data[fieldsData] = $fieldsData;
$this->loadTemplate("FieldMap" , $data);
}
}
function saveMap(){
$tables = $this->dbObj->getTables();
foreach($tables as $table){
$fields = $this->dbObj->getFields($table);
foreach($fields as $field){
$_DATA['data']['tables'][$table]['fields'][] = $field;
$fldName = $table."_".$field[Field];
if($field["PK"]=="PRI"){
$_DATA['data']['tables'][$table]['primary'] = $field[Field];
}
if($_POST["fk_$fldName"] != ""){
$_DATA['data']['tables'][$table]['links'][$field[Field]] = $_POST["fk_$fldName"];
}
$fileContent = var_export($_DATA['data'] , true);
$fileContent = "<?\n\$fieldsData = $fileContent ; \n?>";
$fp = fopen(PATH_DIR."dbMaps/".$_GET[dbID].".php" , "w");
fwrite($fp , $fileContent);
fclose($fp);
header("Location: .");$this->funcPath("MainPage");
}
}
}
}
?>Re: help need with error
Really? Huh, that's strange. You'd think PHP would cry wolf at something like that but I guess as long as they're a matching set it'll parse without problems.superdezign wrote:No, that's perfectly legal. Odd, but legal.
Re: help need with error
As far as I know in some languages defining a block:
introduces a local scope. It's pretty much legal, though not sure what are the benefits of using it in PHP 
Code: Select all
{
int i =0;
....
}There are 10 types of people in this world, those who understand binary and those who don't