A Parse error that shouldnt be

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • micky125
    New Member
    • Sep 2008
    • 36

    #1

    A Parse error that shouldnt be

    Lo all,

    Ive been getting the error message
    Parse error: parse error, unexpected T_ENCAPSED_AND_ WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/moneill/public_html/input.html on line 248

    so ive checked me code over and over again but cant find whats wrong. So getting a annoyed I commented it to move on to next error but the same error message comes up. And when i remove the code completely the error message remains on line 248 but obviously on diff code.

    Code:
    /*
     
    // A Function to total compensation.
    function Compensate()
    {
     global $taskValue, $actualValues, $OriginalPrice, $projectTotal, $Hours, $Price, $Wage;
    
     $thevalue=0;
     for($i=1; $i<=count($Hours); $i++)          //This is compensation for actual work
     {
      $actualValues[$i]= $Hours[$i] * $Wage[$i];
      $theValue       += $actualValues;  
     }
     for($j=1; $j<=count($Price); $j++)           //This is compensation for subcontractors / engineers
     {
      $theValue += $Price[$j];
     }  
     $taskValue     = $OriginalPrice-$theValue;
     $projectValues+= $taskValue;				 
    }
    
    
    */
    The code is of a program of about 850 lines with about 20 functions in it. The hand in date is very soon so cant afford to change it in a major way.

    Has any1 any ideas on this?
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    It would have been nice to point out which is row 248.
    The syntax looks OK, but echo out the variables to see what is in them.
    I suspect you have a string in one of the globals.
    By the way there are a lot poor habits in this short piece of code.
    In fact looking again the problem may be here
    [PHP]$actualValues[$i]= $Hours[$i] * $Wage[$i];
    $theValue += $actualValues; [/PHP]
    $actualValues can't be a variable and an array

    Comment

    • micky125
      New Member
      • Sep 2008
      • 36

      #3
      is my programming really that bad?

      You are probably right with the array / variable thing but even when i comment it out or remove it completely it still says there is the same error. In the case of comments it points to the line within the comment. In the case of removing it, the error is still on line 248 only there is different code there. Could it be the way in which i have variables = signs lining up together could cause too much white space in the program?

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        You say that section of code you posted was commented out, yet you still got the error. That tells me 1 thing: the error isn't in that piece of code you posted.

        Comment

        • code green
          Recognized Expert Top Contributor
          • Mar 2007
          • 1726

          #5
          The error being reported indicates a simple syntax error.
          If you comment out line 248 and still get the error being reported there then the problem is on a line prior to that and could be down to a missing brace '}'

          Comment

          • micky125
            New Member
            • Sep 2008
            • 36

            #6
            I thought that too but there i have kept the }'s all in line...

            BTW I did a bit extra work (take out some white spaces) before i left today so the program lines have changed a bit.

            Code:
            <html>
            <head><title>InputDelayDetails</title></head>
            <?PHP 
            
            $link = mysql_connect("localhost", "space", "ashbyLevel4"); // Connect to server and MySQL database
            if(!$link)
            {
            echo "Could not connect to database..."; // produce an error if you can not connect and exit
            exit;
            }
            
            mysql_select_db("spaceDB");       // select my database on the server newton
              include("input.html");   // include the registration page as we are collecting the data to be                                                         // inserted into the database from here
              
            //Project Variables
            $ProjName=$_POST['ProjName'];
            $projectFloat;
            $projectExtension;
            $projectExcusable;
            $ProjectNonExcusable;
            $projectDelays;    
            $projectValue;
            $liquidateddamages;
            $totalliquidateddamages;
            
            //Individual Task Variables - General
            $Task=$_POST['Task'];
            $Start=$_POST['Start'];
            $End=$_POST['End'];
            $Delay=$_POST['Delay'];
            $taskValue;
            $taskExtension;
            
            //Individual Task Variables - Specific
            $Amount         =$_POST['Amount'];
            $Excusable      =$_POST['Excusable'];
            $Critical       =$_POST['Critical'];
            $AffectCritPath =$_POST['AffectCritPath'];
            $Amount1        =$_POST['Amount1'];
            $Variation      =$_POST['Variation'];
            $Concurrent     =$_POST['Concurrent'];
            $Design         =$_POST['Design'];
            $Reason         =$_POST['Reason'];
            $Proof          =$_POST['Proof'];
            $Mitigation     =$_POST['Mitigation'];
            $Comments       =$_POST['Comments'];
            $OriginalPrice  =$_POST['OriginalPrice'];
            $ConcurrentDelay=$_POST['ConcurrentDelay'];
            
            //Email Variables
            $EmailFrom   =$_POST['EmailFrom[]'];
            $EmailTo     =$_POST['Emailto[]'];
            $EmailDate   =$_POST['EmailDate[]'];
            $EmailSubject=$_POST['EmailSubject[]'];
            $EmailMessage=$_POST['EmailMessage[]'];
            
            //Valuation (Actual work)
            $Date =$_POST['Date[]'];                                  //line 57
            $Staff=$_POST['Staff[]'];
            $Wage =$_POST['Wage[]'];
            $Hours=$_POST['Hours[]'];
            $actualValues;
            $actualRemoved;
            
            //Valuation (Subcontractors / Engineers)
            $SubDate=$_POST('SubDate[]');
            $Subs   =$_POST['Subs[]'];
            $Price  =$_POST['Price[]'];
            $Type   =$_POST['Type[]'];
            $subRemoved;
            
            //Valuation (Plant)
            $PlantDate  =$_POST('PlantDate[]');
            $Plant      =$_POST('Plant[]');
            $PlantType  =$_POST('PlantType[]');
            $PlantCharge=$_POST('PlantCharge[]');
            $PlantDays  =$_POST('PlantDays[]');
            $PlantTotals;
            
            //Connected Delays
            $CDelay1=$_POST['CDelay1'];
            $CDelay2=$_POST['CDelay2'];
            
            //Program Variables
            $valueReduction =0;
            $Total=0;
            $Extension = 0;
            $num=0;
            $AllTotal=0;
            $Extended=0;
            $flag = "OK";
            $msg ="";
            
            function validate()               // between 90 and 96
            {
             global $flag, $message;
            
             //Validate data that has been entered into the project name, start and end date and amount
             if (!$ProjectName)   // User must enter these fields 
             {
              $msg =$msg."You have not indicated a project name<br>";
              $flag="NotOK";
             }
             if (!$Excusable)   // User must enter these fields 
             {
              $msg =$msg."You have not indicated whether delay is excusable or not<br>";
              $flag="NotOK";
             }
             if (!$Start)   // User must enter these fields 
             {
              $msg =$msg."You have not indicated the task start date<br>";
              $flag="NotOK";
             }
             if (!$End)   // User must enter these fields 
             {
              $msg =$msg."You have not indicated a project end date<br>";
              $flag="NotOK";
             }
             if (!$Amount)   // User must enter these fields 
             {
              $msg =$msg."You have not indicated a delay amount<br>";
              $flag="NotOK";
             }
             if(!ereg('[^0-9]', $Amount))
             {    
              $msg=$msg."Please enter numbers only for the Amount of days the task was delayed <BR>";
              $flag="NotOK";   
             }
             for($i=1; $i<=2; $i++)             //127
             {
              if ($i=="1")
              {
               $temp=$Start;
              }
              else
              {
               $temp=$End;                                                //line 130
              }
              $arr=split("/",$temp);                                      // splitting the array
              $dd = $arr[0];                                              // first element of the array is day
              $mm = $arr[1];                                              // second element is date
              $yy = $arr[2];                                              // third element is year
              if(!checkdate($dd,$mm,$yy))
              {
               if($i=="1")
               {
                $msg=$msg."You have inputted an invalid task start date. <br>";
               }
               if($i=="2")
               {
                $msg=$msg."You have inputted an invalid task end date. <br>";
               }
               $flag="NotOK";
              }
             } 
             //Validate the dates putinto variation actual and subs
             if(($Date!="")|| ($Date!=False)||($Date!=NULL))
             {
              for($i=1; $i<=count($Date); $i++)
              {
               $arr=split("/",$Date[$i]);              // splitting the array
               $dd =$arr[0];                           // first element of the array is day
               $mm =$arr[1];                           // second element is date
               $yy =$arr[2];                           // third element is year
               if(!checkdate($dd,$mm,$yy))
               {
                $msg=$msg."You have inputted an invalid valuation date with ".$Date[$i].". <br>";
                $flag="NotOK";
               }
               if(!ereg('[^A-Za-z0-9]', $Staff[$i]))                                                                 // 167
               {
                $msg=$msg."Please enter valid staff names within valuation table. Error with ".$Staff[$i]."<br>";
                $flag="NotOK";
               }
              }
             }
             if(($SubDate!="")|| ($SubDate!=False)||($SubDate!=NULL))
             { 
              for($i=1; $i<=count($SubDate); $i++)
              {
               $arr=split("/",$SubDate[$i]);           // splitting the array
               $dd =$arr[0];                           // first element of the array is day
               $mm =$arr[1];                           // second element is date
               $yy =$arr[2];                           // third element is year
               if(!checkdate($dd,$mm,$yy))
               {
                $msg=$msg."You have inputted an invalid sub date on line ".$i.". <br>";
                $flag="NotOK";
               }
              }
             }
             if(($Staff!="")|| ($Staff!=False)||($Staff!=NULL))
             {
              for($j=1; $j<=count($Staff); $j++)                                              //commented
              {
               if(!ereg('[^A-Za-z0-9]', $Staff[$j]))
               {
                $msg=$msg."Please enter valid staff within variation table <br>";
                $flag="NotOK";
               }
               if(!ereg('[^0-9]', $Hours[$j]))
               {
                $msg=$msg."Please enter valid hours within variation table <br>";
                $flag="NotOK";
               }
              }
             }
            }                    //199
            function getProjectDetails()
            {
             global $ProjName;
              $temp =mysql_query(
                         "SELECT   'Float', 'Extension', 'Excusable', 'NonExcusable', 'Delays', 'Value', 'LiquidatedDamages', 'totalLiquidatedDamages' 
                          FROM     'ProjectDetails'
                          WHERE    'Name'= '$ProjName'" );
              $row = mysql_fetch_array($temp);
              return $row;
            }
            // A function to allow overall project variables to be manipulated.
            function makeVariableProjectDetails()
            {
             global $projectFloat, $projectExtension, $projectExcusable, $projectNonExcusable, $projectDelays, $projectValue, $liquidateddamages, $totalliquidateddamages;
             $temp = getProjectDetails(); 
             $projectFloat          = $temp['ProjectFloat'];
             $projectExtension      = $temp['Extension'];
             $projectExcusable      = $temp['Excusable'];
             $projectNonExcusable   = $temp['NonExcusable'];  
             $projectDelays         = $temp['Delays'];
             $projectValue          = $temp['Value'];
             $liquidateddamages     = $temp['LiquidatedDamages'];
             $totalliquidateddamages= $temp['totalLiquidatedDamages'];
            }
            // A Function to total compensation.
            function Compensate()
            {
             global $taskValue, $actualValues, $OriginalPrice, $projectTotal, $Hours, $Price, $Wage;
            
             $thevalue=0;
             for($i=1; $i<=count($Hours); $i++)          //This is compensation for actual work
             {
              $actualValues[$i]= $Hours[$i] * $Wage[$i];
              $theValue       += $actualValues;  
             }
             for($j=1; $j<=count($Price); $j++)           //This is compensation for subcontractors / engineers
             {
              $theValue += $Price[$j];
             }  
             $taskValue     = $OriginalPrice-$theValue;
             $projectValues+= $taskValue;				 
            }
            // Work out if an extension of time is due for total project completion.
            function isExtended()                  
            {
             global $projectFloat, $AffectCritPath, $projectExtension, $projectExcusable, $projectNonExcusable, $Critical, $Excusable, $Amount, $Amount1, $taskExtension, $totalliquidateddamages, $liquidateddamages; 
             
             $temp=0;
             if ($Excusable =="Yes")
             {
              $taskExtension = $Amount;
             }
             else
             {
              $taskExtension = 0;
             }
             if(($Critical== "No") && ($AffectCritPath== "No"))
             {
              if ($Excusable== "Yes")
              {
               $projectExcusable+= $Amount;
              }
              else
              {
               $projectNonExcusable += $Amount;
              }
             } 
             if($Critical=="Yes")
             {
              $temp = $Amount;
              $continue="Ok";
              if($Excusable =="Yes")
              {
               $projectExcusable += $Amount;
              }
              else
              {
               $projectNonExcusable += $Amount;
              }
             }
             if(($Critical== "No")&&($AffectCritPath== "Yes"))  
             {
              $temp = $Amount1;
              $continue="Ok"; 
              if($Excusable == "Yes")
              {
               $projectExcusable += $Amount1;
              }
              else
              {
               $projectNonExcusable += $Amount1;
              }
             }
             if($continue=="Ok")
             {
              if($projectFloat == "0") 
              {
               $projectExtension      += $temp;
               $totalliquidateddamages+=($liquidateddamages * $temp); 
               $taskExtension          = $temp;
              }
              elseif($projectFloat >= $temp)
              {
               $projectFloat -= $temp;
              }
              else 
              {
               $projectExtension      += ($temp - $projectFloat);
               $totalliquidateddamages+=($liquidateddamages * ($temp-$projectFloat));
               $projectFloat           = 0;
              }
             }
            }
            //Calculates the difference between two dates
            function dateDiff($dformat, $endDate, $beginDate) 
            {
             $date_part1=explode($dformat, $beginDate);
             $date_part2=explode($dformat, $endDate);
             $start_date=gregoriantojd($date_parts1[1], $date_parts1[0], $date_parts1[2]);
             $end_date  =gregoriantojd($date_parts2[1], $date_parts2[0], $date_parts2[2]);
             return $end_date - $start_date;
            }
            
            function numDate($dformat, $date)
            {
             $date_part=explode($dformat, $date);
             $numDate=gregoriantojd($date_part[1], $date_part[0], $date_part[2]); 
             return $numDate;
            }
            
            // A function to find concurrent delays relating to input task
            function getDetails($theTask)  
            {
             global $ProjName;
             
                $temp    = mysql_query(
                       "SELECT   `ProjectName`, `Task`, `Start`,`End`,`Excusable`, `Amount`, `CDelay1`, `CDelay2` 
                        FROM     `Delay`
                        WHERE    `ProjectName`= `$ProjName`
            	        AND      `Delay.Task` = `Concurrent.Task`
            	        AND      `Task` = `$theTask`
                        ASC" );
              $row = mysql_fetch_array($temp);
              return $row;
            }
            
            
            // A function to determine connected delays to current delay
            function getAllRelCons() 
            {
             global $CDelay1, $CDelay2, $conNum1, $conNum2;
             $i=0;
             $count=1;
             
             $conNum[$i][1] = $CDelay1;
             $conNum[$i][2] = $CDelay2;
             $more1 = getDetails($CDelay1);
             $more2 = getDetails($CDelay2);
             for($i=1; $i<=$count; $i++)
             {                                                 
               if($more1['CDelay1']!="FALSE")
               {
                $count += 1;
                $conNum[$count][1] = $more1['CDelay1'];
                $more1=getDetails($more1['CDelay1']);            
               }
            
               if($more1['CDelay2']!="FALSE")                   // Check 2nd Delay
               {
                $conNum[$count][2] = $more1['CDelay2'];
                $more1=getDetails($more1['CDelay2']);
               }
            
               if($more2['CDelay1']!="FALSE")
               {
                $count += 1;
                $conNum[$count][1] = $more2['CDelay1'];
                $more2=getDetails($more2['CDelay1']);
               }
            
               if($more2['CDelay2']!="FALSE")
               {
                $conNum[$count][2] = $more2['CDelay2'];
                $more2=getDetails($more2['CDelay2']);
               }
             }
            } 
            
            function getActualValuations($taskName)
            {
             global $ProjName;
             $temp =mysql_query(
                         "SELECT   'Date', 'Staff', 'actualValues' 
                          FROM     'ValuationActual'
                          WHERE    'ProjectName'= '$ProjName'
            	      AND      'Task'       = '$taskName'
                          ASC" );
              $row = mysql_fetch_array($temp);
              return $row;
            }
            
            function getSubValues($taskName)
            {
             global $ProjName;
              $temp =mysql_query(
                         "SELECT   'Date', 'Staff', 'Price' 
                          FROM     'ValuationSubs'
                          WHERE    'ProjectName'= '$ProjName'
            	      AND      'Task'       = '$taskName'
                          ASC" );
              $row = mysql_fetch_array($temp);
              return $row;
            }
            
            function modify($theDate, $theStaff)
            {
             global $ProjName;
             
             mysql_query(
               "UPDATE ValuationActual
                SET    Removed     = 'Yes' 
                WHERE  ProjectName = $ProjName
                AND    Date        = $theDate
                AND    Staff       = $theStaff");
            }
            
            function modifySubs($theDate, $theStaff)
            {
             global $ProjName;
             
             mysql_query(
               "UPDATE ValuationSubs
                SET    Removed     = Yes 
                WHERE  ProjectName = $ProjName
                AND    Date        = $theDate
                AND    Subs        = $theStaff");
            }
             
            function removeValueTotals()
            {
             global $removingActual, $removingSub, $taskValue, $projectValue, $valueReduction;
             $tempTotal = 0;
             $tempTotal1=0;
            
             for($i=1; $i<=count($removingActual); $i++)
             {
              modify($removingActual[$i]['Date'], $removingActual[$i]['Staff']);
              $tempTotal += $removingActual[$i]['actualValue'];
             }
             for($i=1; $i<=count($removingSub); $i++)
             {
              modifysubs($removingSub[$i]['Date'], $removingSub[$i]['Subs']);
              $tempTotal1 += $removingSub[$i]['Price'];
             }
             $valueReduction = $projectValue - ($tempTotal + $tempTotal1);
             $projectValue  -=($tempTotal + $tempTotal1);
            }
            
            function findValuations($taskName, $theStartDate, $theEndDate, $isActualRSub)
            {
             global $removingActual, $removingSub, $actualValues, $subValues;
             $count=1;
             $i    =0;
             $startFlagged = "No";
             $endFlagged   = "No";
             if($isActualRSub=="Actual")
             {
              $tempValues = getActualValuations($taskName);
              $num        = mysql_num_rows($result);
             }
             else											
             {
              $tempValues = getSubvalues($taskName);
              $num        = mysql_num_rows($result);      
             }
             for($i=1; $i<=$num; $i++)                               // While statement I think this for has to be placed above 1st if
             {
              if(($startFlagged!="Yes") && ($endFlagged!="yes"))     // find the record with start date
              {
               if(($startFlagged == "Yes") && ($endFlagged!="yes"))  // check record between start and end
               {
                if($actualValues[$i]['Date']==$theEndDate)			 // check if record equals end date
                {
                 if($actualValues[$i+1]['Date'] !=$theEndDate) 	 // check whether it is last end date
                 {
                  $endFlagged = "Yes";                               // flag last end date record
                 }
                }
                if($isActualRSub=="Actual")
                {
                 $removingActual[$count] = $tempValues[$i];
                }
                else
                {
                 $removingSub[$count] = $tempValues[$i];
                }
                $count += 1;
               }
               else 
               {
                if($actualValues[$i]['Date'] == $theStartDate)
                {
                 if($isActualRSub=="Actual")
                 {
                  $removingActual[$count] = $tempValues[$i];      // check this
                 }
                 else
                 {
                  $removingSub[$count] = $tempValues[$i];
                 }
                 $count +=1;
                 if($startflagged != "Yes")                          // test whether it has been flagged?
                 {
                  $startflagged = "Yes";                       		 // flag start of values to be disregarded
                 }
                }
               }
              }
             }
            }
             
            function findInputValues($theStart, $theEnd, $actualRSub)
            {
             global $Staff, $Subs, $taskValue, $actualValues, $actualRemoved, $subRemoved;
             $startFlagged = "No";
             $endFlagged = "No";
             
             if($actualRSub == "Actual")                  // the mysql fetch array needs to be inside loop
             {
              for($i=1; $i<=count($Staff); $i++)
              {
               $temp[$i] = $Staff[$i];
              }
             }
             else
             {
              for($i=1; $i<=count($Subs); $i++)
              {
               $temp[$i] = $Subs[$i];
              }
             }
             for($i=1; $i<=count($temp); $i++)
             {
              if(($startFlagged!="Yes") && ($endFlagged!="yes"))
              {
               if(($startFlagged == "Yes") && ($endFlagged!="yes"))
               {
                if($temp[$i]==$theEndDate)
                {
                 if($temp[$i+1] !=$theEndDate) 		 
                 {
                  $endFlagged = "Yes";                               
                 }
                }
                if($actualRSub=="Actual")
                {
                 $taskValue       -= $actualValues[$i];
                 $projectValue    -= $actualValues[$i];
                 $actualRemoved[$i]= "Yes"; 
                }
                else
                {
                 $taskValue    -= $Price[$i];
                 $projectValue -= $Price[$i];
                 $subRemoved[$i]= "Yes";
                }
               }
               else
               {
                if($temp[$i] == $theStartDate)
                {
            	 if($isActualRSub=="Actual")
            	 {
            	 $taskvalue       -= $actualvalues[$i];
            	 $projectValue    -= $actualValue[$i];
            	 $actualRemoved[$i]= "Yes";
            	 }
            	 else
            	 {
            	  $taskValue    -= $Price[$i];
            	  $projectValue -= $Price[$i];
            	  $subRemoved[$i]= "Yes";
            	 }
            	 if($startflagged != "Yes")                     // test whether it has been flagged?
            	 {
                      $startflagged = "Yes";                        // flag start of values to be disregarded
            	 }
                 }
               }
              }
             }
            }
            
            // A function to check concurrency. Concurrency is when there is an excusable and non excusable    
            function isConcurrency()  
            {
             global $Amount, $Amount1, $ConcurrentDelay, $ProjectExtension, $ProjectExcusable,$ProjectNonExcusable, $dontAdd;
             
             $temp   = getDetails($ConcurrentDelay);
             if (($Crit=="No")&&($AffectCritPath=="Yes"))  
             {
              $temp1 = $Amount1;
             }
             else if(($temp['Critical']=="No") && ($temp['AffectCritPath']=="Yes"))
             {
              $temp2 = $temp['Amount1'];
             }
             else
             {
              $temp1 = $Amount;
              $temp2 = $Amount1;
             } 
             $ATotal = dateDiff('/', $End, $Start);
             $BTotal = dateDiff('/', $temp['End'], $temp['Start']);
             $AStart = numDate('/', $End)-$temp1;
             $BStart = numDate('/', $temp['End'])-$temp2;
             $temp3  = $AStart - $BStart;
             if($temp3 >=0)
             {
              if(($BTotal + $temp3) >= $ATotal) 
              {
               if(($Excusable=="Yes") && ($temp['Excusable'] =="No"))
               {
                findInputValues($Start, $End, 'Actual');
                findInputvalues($Start, $End, 'Sub');
               }
               if(($Excusable=="No") && ($temp['Excusable'] =="Yes"))  
               {
                findValuations($ConcurrentDelay, $Start, $End, "Actual");
                findValuations($ConcurrentDelay, $Start, $End, "Sub");
                removeValueTotals();
               }
              }
              else
              {
               $temp4 = dateDiff('/', $temp['End'], $Start);
               if(($Excusable=="Yes") && ($temp['Excusable'] =="No"))
               {
                removeInputValuations($Task, $Start, $temp['End']);
               }
               if(($Excusable=="No") && ($temp['Excusable'] =="Yes"))  
               {
                findValuations($ConcurrentDelay, $Start, $temp['End'], 'Actual');
                findValuations($ConcurrentDelay, $Start, $temp['End'], 'Sub');
                removeValueTotals();
               }
              }
             }
             else
             {
              $temp3 = $temp3 * (-1);
              $temp4 = dateDiff('/', $End, $temp['Start']);
              if(($BTotal - $temp3) >= $ATotal)             
              {
               if(($Excusable=="Yes") && ($temp['Excusable'] =="No"))
               {
                findInputValues($temp['Start'], $End, "Actual");
                findInputvalues($temp['Start'], $End, "Sub");
               }
               if(($Excusable=="No") && ($temp['Excusable'] =="Yes"))  
               {
                removeValuations($ConcurrentDelay, $temp['Start'], $End, "Actual");
                removeValuations($ConcurrentDelay, $temp['Start'], $End, "Subs");
                removeValueTotals();
               }
              }
              else
              {
               if(($Excusable=="Yes") && ($temp['Excusable'] =="No"))
               {
                removeInputValuations($Task, $temp['Start'], $temp['End']);
               }
               if(($Excusable=="No") && ($temp['Excusable'] =="Yes"))  
               {
                removeValuations($ConcurrentDelay, $temp['Start'], $temp['End'], 'Actual');
                removeValuations($ConcurrentDelay, $temp['Start'], $temp['End'], 'Sub');
                removeValueTotals();
               }
              }
             }
            }
            
            // A function to update the project details 
            function updateProjectDetails()
            {
             global $ProjName, $projectFloat, $projectExtension, $projectExcusable, $projectNonExcusable,$projectDelays, $projectValue;
             
             mysql_query(
               "UPDATE ProjectDetails
                SET    ProjectFloat          = $projectFloat
            	   Extension             = $projectExtension
            	   Excusable             = $projectExcusable
                       NonExcusable          = $projectNonExcusable
            	   Delays                = $projectDelays
            	   Value                 = $projectValue
            	   LiquidatedDamages     = $liquidatedDamages
                       totalLiquidatedDamages= $totalLiquidatedDamages
            	WHERE  Name       = $ProjName");
            }
             
            // A function to insert a new record into task details table
            function insertTaskDetails()
            {
             global $taskExtension, $taskValue;
             mysql_query(
                "INSERT INTO Delay 
                (ProjectName, Task, Start, End, Extension, Value, OriginalPrice,  Excusable, Critical, AffectCritPath, Amount, Variation, Concurrent, Design, Reason, Proof, Mitigation, Comments) 
                 VALUES
                   ('$_POST[ProjName]', '$_POST[Task]', '$_POST[Start]', '$_POST[End]', '$taskExtension', '$taskValue', '$_POST[OriginalPrice], '$_POST[Amount]', '$_POST[Excusable]', '$_POST[Critical]', '$_POST[AffectCritPath]', '$_POST[Amount1], '$_POST[Variation]', '$_POST[Concurrent]', '$_POST[Design]', '$_POST[Reason]', '$_POST[Proof]', '$_POST[Mitigation]', '$_POST[Comments])");
            }
            
            // A function to insert a new record into concurrent delays table
            function insertConcurrent()
            {
             mysql_query(
                "INSERT INTO ConcurrentDelays
            	   ( ProjectName, Task, ConcurrentDelay, ValueReduction)
            	 VALUES
            	   ( '$_POST[ProjName]', '$_POST[Task]', '$_POST[ConcurrentDelay]', '$valueReduction' )");
            }	   
            
            // A function to insert a new record into emails table
            function insertEmail($from, $to, $date, $subject, $message)
            {
             mysql_query(
                "INSERT INTO Email
            	   ( ProjectName, Task, EmailFrom, EmailTo, Date, Subject, Message)
            	 VALUES
            	   ( '$_POST[EmailProjName]', '$_POST[EmailTask]', '$EmailFrom', '$EmailTo', '$EmailDate', '$EmailSubject', '$EmailMessage' )");
            }	   
            
            // A function to insert a new record into ValuationActual table
            function insertValuationActual($theDate, $theStaff, $theWage, $theHours, $theActualValues, $theActualRemoved)
            {
             mysql_query(
                "INSERT INTO ValuationActual
            	   ( ProjectName, Task, Date, Staff, Wage, Hours, Value, Removed)
            	 VALUES
            	   ( '$_POST[ProjName]', '$_POST[Task]', '$theDate', '$theStaff', '$theWage', '$theHours', '$theActualValues', '$theActualRemoved' )");
            }
            
            // A function to insert a new record into Valuation (Subcontractors / Engineers) table
            function insertValuationSubs($theDate, $theSubs, $theType, $thePrice, $theSubRemoved)
            {
             mysql_query(
                "INSERT INTO ValuationSubs
            	   ( ProjectName, Task, Date, SubContractor, Type, Price, Removed)
            	 VALUES
            	   ( '$_POST[ProjName]', '$_POST[Task]', '$theDate', '$theSubs', '$theType', '$thePrice',  '$theSubRemoved' )");
            }
            
            // A function to insert a new record into ConnectedDelays
            function insertConnectedDelay()
            {
             mysql_query(
                "INSERT INTO ConnectedDelays
                   ( ProjectName, Task, ConnectedDelay1, ConnectedDelay2 )
            	 VALUES
            	   ( '$_POST[ProjName]', '$_POST[Task]', '$_POST[CDelay2]', '$_POST[CDelay1]' )");
            }
            // The order of the functions to be called to process the delay.
            validate();
            if($flag=="OK")
            {
             makeVariableProjectDetails();
             Compensate();
             isExtended();
             if(($CDelay1!="")|| ($CDelay1!=False)||($CDelay1!=NULL))
             {
              getAllRelCons();
             }
             if($concurrent =="Yes")
             {
              isConcurrency();
              insertConcurrent;
             }
             updateProjectDetails();
             insertTaskDetails();
             if(($EmailDate!="")|| ($EmailDate!=False)||($EmailDate!=NULL))
             {
              for($i=1; $i<=count($EmailFrom); $i++)
              {
               insertEmail($EmailFrom[$i], $EmailTo[$i], $EmailDate[$i], $EmailSubject[$i], $EmailMessage[$i]);
              }
             }
             if(($Date!="")|| ($Date!=False)||($Date!=NULL))
             {
              for($i=1; $i<=count($Date); $i++)
              {
               insertValuationActual($Date[$i], $Staff[$i], $Wage[$i], $Hours[$i], $actualValues[$i],  $actualRemoved[$i]);
              }
             }
             if(($SubDate!="")|| ($SubDate!=False)||($SubDate!=NULL))
             {
              for($i=1; $i<=count($SubDate); $i++)
              {
               insertValuationSubs($SubDate[$i], $Subs[$i], $Price[$i], $subRemoved[$i]); 
              }
             }
             insertConnectedDelay();
            }
            else
            {
             echo $msg;
             echo "hello";
            }
            ?>
            </html>
            I thought i wud post the code... the bit in bold is where the error occurs but it is just functions above it... u can c why it was frustrating :)

            Comment

            • code green
              Recognized Expert Top Contributor
              • Mar 2007
              • 1726

              #7
              Sorry for late reply. But away at weekend
              I dumped your code in a debugger which reported this syntax error.
              Code:
              Fatal error: Function name must be a string in .............
               ...........php on line 66
              You have used round brackets instead of square[PHP]66. $SubDate=$_POST ('SubDate[]'); [/PHP]
              same here [PHP]$PlantDate =$_POST('PlantD ate[]');
              $Plant =$_POST('Plant[]');
              $PlantType =$_POST('PlantT ype[]');
              $PlantCharge=$_ POST('PlantChar ge[]');
              $PlantDays =$_POST('PlantD ays[]');[/PHP] So the form data is not being read as expected.
              This would have been obvious if you had paid heed of my first post
              and echoed out variables.
              Also you cannot have error_reporting switched on because these would be reported.
              Please read the posting rules

              Comment

              • micky125
                New Member
                • Sep 2008
                • 36

                #8
                Code green

                Thanks for the help... but can i ask you how you were able to debug the php without actually having any of the other content, I did not know any software existed as the way i have been debugging is by going to the server using explorer and following it through which only gives one error an line number. It doesnt give that good of a description.

                Another point you made was about error_reporting (E_ALL);

                If i include this at the top of the code will this produce a list of errors that will be output from the server instead of a vague description? It is the first I have heard that php had this function.

                Thanks for the help btw!

                Comment

                • Markus
                  Recognized Expert Expert
                  • Jun 2007
                  • 6092

                  #9
                  If you have a good IDE, like PHPDesigner, it will have a built in debugger that you can run on your code.

                  Mark.

                  Comment

                  • code green
                    Recognized Expert Top Contributor
                    • Mar 2007
                    • 1726

                    #10
                    Yes. I use phpdesigner but I often prefer the method you describe
                    using explorer and following it through which only gives one error an line number. It doesnt give that good of a description.
                    It only reports one fatal error, if there is not too many they can be fixed one at a time.
                    Another point you made was about error_reporting (E_ALL);
                    If i include this at the top of the code will this produce a list of errors
                    that will be output from the server instead of a vague description
                    With experience you will learn what the 'vague' descriptions mean
                    and that the line is where an error occured but not neccesarily the error itself.

                    E_ALL lists non-fatal errors
                    These often point to fundamental errors that may or may not lead to a fatal.
                    I do not allow any of these to pass and use them as a guide to where I need my error traps and tighten up my code.
                    I always use the following [PHP]error_reporting (E_ALL | E_STRICT);
                    ini_set('displa y_errors',1);
                    ini_set('displa y_startup_error s ',1);[/PHP] Can't remember what they all do but give it a try.

                    Comment

                    • micky125
                      New Member
                      • Sep 2008
                      • 36

                      #11
                      sound 1 both of you for helping a newb to php like me. It is appreciated.

                      Comment

                      • Markus
                        Recognized Expert Expert
                        • Jun 2007
                        • 6092

                        #12
                        Originally posted by micky125
                        sound 1 both of you for helping a newb to php like me. It is appreciated.
                        I think I speak for all the guys here at the PHP forum: it's what we do.

                        Comment

                        • micky125
                          New Member
                          • Sep 2008
                          • 36

                          #13
                          hey guys sorry for the long wait for me to test it i only got to the server comp today. The error remains in the code in the same place...(line 250)

                          I have traced through the program and have not been able to rectify the problem... I have even taken out validation, isextended and compensation function calls at the bottom of the code but the same error remains.

                          I am using a companies server, could it be possible that there is permission issues with downloading info from the server but uploading is ok as i can upload from html / php onto sql but when i try and populate a select statement using php it comes up with nothing... I am hoping this might have some thing to do with it?

                          If it doesnt and i am sounding really stupid does any1 no what else the error mite be....

                          Parse error: parse error, unexpected T_ENCAPSED_AND_ WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/moneill/public_html/input.html on line 250

                          I have used phpdesigner and so there r no syntax errors...

                          BTW i dont seem to be able to access .ini for error recovery...

                          Comment

                          • pbmods
                            Recognized Expert Expert
                            • Apr 2007
                            • 5821

                            #14
                            Heya, Micky.

                            What is the code on line 250?

                            Comment

                            • micky125
                              New Member
                              • Sep 2008
                              • 36

                              #15
                              lo pbmods,

                              If you go to the 5th or 6th post i displayed the code that im using. TBH i have tried a lot of things to even by pass the error but it doesnt seem to work and i cant figure it out at all. I did notice last night that a variable in the global ... was not a initialised, r even used, in the program but I dont think this would have caused the error as it would have left it. The value of projectValues was not called global in compensation(re lating to the other global) but this would have kept it to a local variable so i dont think it that. I hope you can make more sense from it than i can...

                              mick.

                              Comment

                              Working...