Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Error: T_CONSTANT_ENCAPSED_STRING
Old 10-12-2010, 02:33 PM Error: T_CONSTANT_ENCAPSED_STRING
Extreme Talker

Posts: 173
Trades: 0
I am getting the following error but cannot see the problem. Can someone please point out the error of my ways?

Line 20 is the if statement

Quote:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\Program Files\EasyPHP-5.3.3\www\pet\display_iso_list.php on line 20
PHP Code:
  foreach ($field_list as $field_name){
   if(empty(
$_POST[$field_name])) $sql.=$field_name'=NULL, ';
   else       
$sql.=$field_name'='.$_POST[$field_name].', ';
  } 
The full code:
PHP Code:
<?php
// set up global variables 
@include 'menu.php';
$field_list=array('co','f','cm','ae','ccr','pm','pc','me','md','ee','ed','ce','src','qa','hr','ehs','mftr','fs','tts','dc');
if(isset(
$_POST["iso_desc"])){ //ISO document is being modified or added
 
if(isset($_POST["id"])){ //ISO document is being modified
  
$sql='UPDATE tbl_list_iso_templates '.
    
'SET iso_desc="'.mysql_real_escape_string($_POST["iso_desc"]).'", '.
        
'url="'.strtolower(mysql_real_escape_string($_POST["url"])).'", ';
  if(empty(
$_POST["revision"])) $sql.='revision=NULL, ';
  else       
$sql.='revision="'.strtoupper(mysql_real_escape_string($_POST["revision"])).'", ';
  if(empty(
$_POST["iso"]))  $sql.='iso=NULL, ';
  else       
$sql.='iso="'.strtoupper(mysql_real_escape_string($_POST["iso"])).'", ';
  if(empty(
$_POST["type"]))  $sql.='document_type=NULL, ';
  else       
$sql.='document_type='.$_POST["type"].', ';
  foreach (
$field_list as $field_name){
   if(empty(
$_POST[$field_name])) $sql.=$field_name'=NULL, ';
   else       
$sql.=$field_name'='.$_POST[$field_name].', ';
  }  
  
//Remove last ',' from string before adding where
  
$sql.=' WHERE iso_template_id='.$_POST['id'];
 }
 else{ 
//ISO document is being added
  
$sql_begin='INSERT INTO tbl_list_iso_templates (iso_desc, url';
  
$sql_end='VALUES ("'.mysql_real_escape_string($_POST["iso_desc"]).'","'.strtolower(mysql_real_escape_string($_POST["url"])).'"';
  if(isset(
$_POST["revision"])){
   
$sql_begin.=', revision';
   
$sql_end.=',"'.strtoupper(mysql_real_escape_string($_POST["revision"])).'"';
  } 
  if(isset(
$_POST["iso"])){
   
$sql_begin.=', iso';
   
$sql_end.=',"'.strtoupper(mysql_real_escape_string($_POST["iso"])).'"';
  }
  if(isset(
$_POST["type"])){
   
$sql_begin.=', document_type';
   
$sql_end.=', '.$_POST["type"];
  }
  foreach (
$field_list as $field_name){
   if (!isset(
$_POST[$field_name])){
    
$sql_begin.=', '.$field_name;
    
$sql_end.=', '.$_POST[$field_name];
      }
  }  
  
$sql=$sql_begin.') '.$sql_end.')';
 }
 echo 
$sql;
 
$result=query($sql);
}
//User setting:  records the columns to be displayed
if(isset($_POST["console"])) my_console($_POST["console"],"interface_iso");
if(isset(
$_GET["sort"])) $sort=$_GET["sort"];
if(isset(
$_GET["r"]))  $r=$_GET["r"];
if(empty(
$sort))$sort="iso";
if(empty(
$r)) $r=0;
//Creates list of projects
//Displays list of project if you want MyProjects only
if (strlen(strstr($_SESSION['interface_iso'],"2"))>0){
  
$sql='SELECT * FROM tbl_list_iso_templates ';
  }
//Displays all ISO Documents
else  $sql='SELECT * FROM tbl_list_iso_templates ';
if   (
$sort=="iso")   $sql.="ORDER BY iso ";
elseif  (
$sort=="desc")  $sql.="ORDER BY iso_desc ";
elseif  (
$sort=="form")  $sql.="ORDER BY document_type ";
foreach (
$field_list as $field_name){
 if (
$sort==$field_name){
  
$sql.="ORDER BY ".$field_name;
  break;
    }
}  
if (
$r==1$sql.=" DESC ";
else  
$sql.=" ASC ";
//Determines if user wants to view or modify console
$result query($sql);
for (
$x=0;$x<strlen($_SESSION['interface_iso']);$x++){
 if(isset(
$_GET["modify"]))   $col[$x]=1;
 elseif(isset(
$_GET["edit"]))  $col[$x]=1;
 elseif(isset(
$_GET["new"]))  $col[$x]=1;
 else       
$col[$x]=substr($_SESSION['interface_iso'],$x,1);
}
echo 
'<body><table class="datagrid"><tr>';
if(isset(
$_GET["edit"])){  //edit the values in a given recordset
 
$tabindex=0;
 
$sql='SELECT * FROM tbl_list_iso_templates WHERE iso_template_id='.$_GET["edit"];
 
$row mysql_fetch_assoc(query($sql));
 
$str_edit='<form action="display_iso_list.php" method="post">'.
    
'<table class="datagrid"><tr>'.
     
'<td><input type="submit" value="Update" />'.
     
'<input type="hidden" name="id" value="'.$row['iso_template_id'].'"></td>'.
      
'<td><input maxlength="70" size="70" type="text" name="iso_desc" value="'.$row['iso_desc'].'" tabindex="'.$tabindex++.'"></td>'.
      
'<td><input maxlength="40" size="10" type="text" name="iso" value="'.$row['iso'].'" tabindex="'.$tabindex++.'"></td>'.
      
'<td><input maxlength="3" size="1" type="text" name="revision" value="'.$row['revision'].'" tabindex="'.$tabindex++.'"></td>'.
      
'<td><input maxlength="255" size="80" type="text" name="url" value="'.$row['url'].'" tabindex="'.$tabindex++.'"></td>';
     if(empty(
$row['document_type'])) $str_edit.='<td><input type="checkbox" name="type" value="1" tabindex="'.$tabindex++.'"></td>';
     else        
$str_edit.='<td><input type="checkbox" name="type" value="1" checked tabindex="'.$tabindex++.'"></td>';
     foreach (
$field_list as $field_name){
       if(empty(
$row[$field_name]))$str_edit.='<td><input type="checkbox" name="type" value="1" tabindex="'.$tabindex++.'"></td>';
      else      
$str_edit.='<td><input type="checkbox" name="type" value="1" checked tabindex="'.$tabindex++.'"></td>';
     } 
     
$str_edit.='<td><input type="submit" value="Update" /></td></tr>';
 echo 
$str_edit;
}
if(isset(
$_GET["new"])){  //edit the values in a given recordset
 
$tabindex=0;
 
$str_new='<form action="display_iso_list.php" method="post">'.
    
'<table class="datagrid"><tr>'.
     
'<td><input type="submit" value="Add" /></td>'.
      
'<td><input maxlength="70" size="70" type="text" name="iso_desc" tabindex="'.$tabindex++.'"></td>'.
      
'<td><input maxlength="40" size="10" type="text" name="iso" tabindex="'.$tabindex++.'"></td>'.   
      
'<td><input maxlength="3" size="1" type="text" name="revision" tabindex="'.$tabindex++.'"></td>'.
      
'<td><input maxlength="255" size="40" type="text" name="url" tabindex="'.$tabindex++.'"></td>'.
     
'<td><input type="checkbox" name="type" value="1" checked tabindex="'.$tabindex++.'"></td>';
     foreach (
$field_list as $field_name){
      
$str_header.='<td><input type="checkbox" name="type" value="1" checked tabindex="'.$tabindex++.'"></td>';
     }  
     
$str_new.='<td><input type="submit" value="Add" /></td>'.
    
'</tr>'
 echo 
$str_new;
}
//Create datagrid header
if(isset($_GET["modify"])){
    
$str_modify.='<form action="display_iso_list.php" method="post">'.
   
'<tr>'.
    
'<td><input type="submit" value="Update" />&nbsp&nbsp&nbsp&nbsp&nbsp  </td>'.
    
'<td>Console: '.
    
'<select name="console[]">';
     if (
$col[0]==1$str_header.='<option value="1" selected="selected">All Documents</option>';
     else   
$str_header.='<option value="1" >All Documents</option>';
     if (
$col[0]==2$str_header.='<option value="2" selected="selected">My Documents</option>';
     else   
$str_header.='<option value="2" >My Documents</option>';
     
$str_header.='</select></td>';
    for (
$x=1;$x<strlen($_SESSION['interface_iso']);$x++){
     
$str_header.='<td><input type="checkbox" name="console[]" value="'.$x.'" checked></td>';
    }
 
$str_modify.='</tr></form>';
 echo 
$str_modify;
}
 
$x=1;
 
$str_header='<th><a href="display_iso_list.php?new=1"><img src="images/bluecross.gif" alt="New..."></a></th>'.
    
'<th><a href="display_iso_list.php?sort=desc&r='.!$r.'"><b>Description</b></a></th>';
 if (!empty(
$col[$x++])) $str_header.='<th><a href="display_iso_list.php?sort=iso&r='.!$r.'"><b>ISO</b></a></th>';
  if (!empty(
$col[$x++])) $str_header.='<th><b>Revision</b></th>';
 if (!empty(
$col[$x++])) $str_header.='<th><b>url</b></td>';
 if (!empty(
$col[$x++])) $str_header.='<th><a href="display_iso_list.php?sort=form&r='.!$r.'"><b>Type</b></a></td>';
 foreach (
$field_list as $field_name){
  if (!empty(
$col[$x++])) $str_header.='<th><a href="display_iso_list.php?sort='.$field_name.'&r='.!$r.'"><b>'.strtoupper($field_name).'</b></a></th>';
 }  
 if (!empty(
$col[$x++])) $str_header.='<th><a href="display_iso_list.php?new=1"><img src="images/bluecross.gif" alt="New..."></a></th>';
 
$str_header.='</tr>';
 
 
//Create datagrid
$x=1;
 
$i=0;
 while (
$row mysql_fetch_assoc($result)) {  
  if(
$_SESSION['header_repeat']==&& $i==0)  echo $str_header//Repeats header based on user setting
  
elseif(!empty($_SESSION['header_repeat'])){
   
$remainder=$i $_SESSION['header_repeat'];
   if(empty(
$remainder))       echo $str_header//Repeats header based on user setting
  
}
  
$i++;
  
$str_row='<tr class=d'.($i 1).'>'.
   
'<td><a href="display_iso_list.php?edit='.$row['iso_template_id'].'"><img src="images/pencil.gif" alt="Edit"></a></td>'.
      
'<td align = "left"><a href="'.$row['url'].'" target="_blank">'.$row['iso_desc'].'</a></td>';
     if (!empty(
$col[$x++])) $str_row.='<td><a href="'.$row['url'].'" target="_blank">'.$row['iso'].'</a></td>';
     if (!empty(
$col[$x++])) $str_row.='<td>'.$row['revision'].'</td>';
     if (!empty(
$col[$x++])) $str_row.='<td><a href="'.$row['url'].'" target="_blank">'.$row['url'].'</a></td>';
     if (!empty(
$col[$x++])) {
   if(empty(
$row['document_type']))$str_row.='<td>Form</td>';
   else       
$str_row.='<td>WI</td>';
  }
  foreach (
$field_list as $field_name){
      if (!empty(
$col[$x++])){
    if(!empty(
$row[$field_name])) $str_row.='<td><img src="images/ok.gif"></td>';
    else       
$str_row.='<td></td>';
   }
  }  
     if (!empty(
$col[$x++])) $str_row.='<td><a href="display_iso_list.php?edit='.$row['iso_template_id'].'"><img src="images/pencil.gif" alt="Edit"></a></td>';
  
$str_row.='</tr>';
  
$x=1;
  echo 
$str_row;
  }   
 echo 
'</table>';
}
 echo 
'</body></html>';
?>
dgkindy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-12-2010, 03:03 PM Re: Error: T_CONSTANT_ENCAPSED_STRING
Experienced Talker

Posts: 47
Trades: 0
Use . to connect strings and $vars
Code:
  foreach ($field_list as $field_name){
   if(empty($_POST[$field_name])) $sql.=$field_name .'=NULL, ';
   else       $sql .= $field_name .'='. $_POST[$field_name].', ';
  }
NextToNothing is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Error: T_CONSTANT_ENCAPSED_STRING
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.91284 seconds with 12 queries