By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,751 Members | 1,216 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,751 IT Pros & Developers. It's quick & easy.

A Parse error that shouldnt be

P: 36
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.

Expand|Select|Wrap|Line Numbers
  1. /*
  2.  
  3. // A Function to total compensation.
  4. function Compensate()
  5. {
  6.  global $taskValue, $actualValues, $OriginalPrice, $projectTotal, $Hours, $Price, $Wage;
  7.  
  8.  $thevalue=0;
  9.  for($i=1; $i<=count($Hours); $i++)          //This is compensation for actual work
  10.  {
  11.   $actualValues[$i]= $Hours[$i] * $Wage[$i];
  12.   $theValue       += $actualValues;  
  13.  }
  14.  for($j=1; $j<=count($Price); $j++)           //This is compensation for subcontractors / engineers
  15.  {
  16.   $theValue += $Price[$j];
  17.  }  
  18.  $taskValue     = $OriginalPrice-$theValue;
  19.  $projectValues+= $taskValue;                 
  20. }
  21.  
  22.  
  23. */
  24.  
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?
Oct 3 '08 #1
Share this Question
Share on Google+
15 Replies


code green
Expert 100+
P: 1,726
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
Oct 3 '08 #2

P: 36
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?
Oct 3 '08 #3

Markus
Expert 5K+
P: 6,050
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.
Oct 3 '08 #4

code green
Expert 100+
P: 1,726
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 '}'
Oct 3 '08 #5

P: 36
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.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head><title>InputDelayDetails</title></head>
  3. <?PHP 
  4.  
  5. $link = mysql_connect("localhost", "space", "ashbyLevel4"); // Connect to server and MySQL database
  6. if(!$link)
  7. {
  8. echo "Could not connect to database..."; // produce an error if you can not connect and exit
  9. exit;
  10. }
  11.  
  12. mysql_select_db("spaceDB");       // select my database on the server newton
  13.   include("input.html");   // include the registration page as we are collecting the data to be                                                         // inserted into the database from here
  14.  
  15. //Project Variables
  16. $ProjName=$_POST['ProjName'];
  17. $projectFloat;
  18. $projectExtension;
  19. $projectExcusable;
  20. $ProjectNonExcusable;
  21. $projectDelays;    
  22. $projectValue;
  23. $liquidateddamages;
  24. $totalliquidateddamages;
  25.  
  26. //Individual Task Variables - General
  27. $Task=$_POST['Task'];
  28. $Start=$_POST['Start'];
  29. $End=$_POST['End'];
  30. $Delay=$_POST['Delay'];
  31. $taskValue;
  32. $taskExtension;
  33.  
  34. //Individual Task Variables - Specific
  35. $Amount         =$_POST['Amount'];
  36. $Excusable      =$_POST['Excusable'];
  37. $Critical       =$_POST['Critical'];
  38. $AffectCritPath =$_POST['AffectCritPath'];
  39. $Amount1        =$_POST['Amount1'];
  40. $Variation      =$_POST['Variation'];
  41. $Concurrent     =$_POST['Concurrent'];
  42. $Design         =$_POST['Design'];
  43. $Reason         =$_POST['Reason'];
  44. $Proof          =$_POST['Proof'];
  45. $Mitigation     =$_POST['Mitigation'];
  46. $Comments       =$_POST['Comments'];
  47. $OriginalPrice  =$_POST['OriginalPrice'];
  48. $ConcurrentDelay=$_POST['ConcurrentDelay'];
  49.  
  50. //Email Variables
  51. $EmailFrom   =$_POST['EmailFrom[]'];
  52. $EmailTo     =$_POST['Emailto[]'];
  53. $EmailDate   =$_POST['EmailDate[]'];
  54. $EmailSubject=$_POST['EmailSubject[]'];
  55. $EmailMessage=$_POST['EmailMessage[]'];
  56.  
  57. //Valuation (Actual work)
  58. $Date =$_POST['Date[]'];                                  //line 57
  59. $Staff=$_POST['Staff[]'];
  60. $Wage =$_POST['Wage[]'];
  61. $Hours=$_POST['Hours[]'];
  62. $actualValues;
  63. $actualRemoved;
  64.  
  65. //Valuation (Subcontractors / Engineers)
  66. $SubDate=$_POST('SubDate[]');
  67. $Subs   =$_POST['Subs[]'];
  68. $Price  =$_POST['Price[]'];
  69. $Type   =$_POST['Type[]'];
  70. $subRemoved;
  71.  
  72. //Valuation (Plant)
  73. $PlantDate  =$_POST('PlantDate[]');
  74. $Plant      =$_POST('Plant[]');
  75. $PlantType  =$_POST('PlantType[]');
  76. $PlantCharge=$_POST('PlantCharge[]');
  77. $PlantDays  =$_POST('PlantDays[]');
  78. $PlantTotals;
  79.  
  80. //Connected Delays
  81. $CDelay1=$_POST['CDelay1'];
  82. $CDelay2=$_POST['CDelay2'];
  83.  
  84. //Program Variables
  85. $valueReduction =0;
  86. $Total=0;
  87. $Extension = 0;
  88. $num=0;
  89. $AllTotal=0;
  90. $Extended=0;
  91. $flag = "OK";
  92. $msg ="";
  93.  
  94. function validate()               // between 90 and 96
  95. {
  96.  global $flag, $message;
  97.  
  98.  //Validate data that has been entered into the project name, start and end date and amount
  99.  if (!$ProjectName)   // User must enter these fields 
  100.  {
  101.   $msg =$msg."You have not indicated a project name<br>";
  102.   $flag="NotOK";
  103.  }
  104.  if (!$Excusable)   // User must enter these fields 
  105.  {
  106.   $msg =$msg."You have not indicated whether delay is excusable or not<br>";
  107.   $flag="NotOK";
  108.  }
  109.  if (!$Start)   // User must enter these fields 
  110.  {
  111.   $msg =$msg."You have not indicated the task start date<br>";
  112.   $flag="NotOK";
  113.  }
  114.  if (!$End)   // User must enter these fields 
  115.  {
  116.   $msg =$msg."You have not indicated a project end date<br>";
  117.   $flag="NotOK";
  118.  }
  119.  if (!$Amount)   // User must enter these fields 
  120.  {
  121.   $msg =$msg."You have not indicated a delay amount<br>";
  122.   $flag="NotOK";
  123.  }
  124.  if(!ereg('[^0-9]', $Amount))
  125.  {    
  126.   $msg=$msg."Please enter numbers only for the Amount of days the task was delayed <BR>";
  127.   $flag="NotOK";   
  128.  }
  129.  for($i=1; $i<=2; $i++)             //127
  130.  {
  131.   if ($i=="1")
  132.   {
  133.    $temp=$Start;
  134.   }
  135.   else
  136.   {
  137.    $temp=$End;                                                //line 130
  138.   }
  139.   $arr=split("/",$temp);                                      // splitting the array
  140.   $dd = $arr[0];                                              // first element of the array is day
  141.   $mm = $arr[1];                                              // second element is date
  142.   $yy = $arr[2];                                              // third element is year
  143.   if(!checkdate($dd,$mm,$yy))
  144.   {
  145.    if($i=="1")
  146.    {
  147.     $msg=$msg."You have inputted an invalid task start date. <br>";
  148.    }
  149.    if($i=="2")
  150.    {
  151.     $msg=$msg."You have inputted an invalid task end date. <br>";
  152.    }
  153.    $flag="NotOK";
  154.   }
  155.  } 
  156.  //Validate the dates putinto variation actual and subs
  157.  if(($Date!="")|| ($Date!=False)||($Date!=NULL))
  158.  {
  159.   for($i=1; $i<=count($Date); $i++)
  160.   {
  161.    $arr=split("/",$Date[$i]);              // splitting the array
  162.    $dd =$arr[0];                           // first element of the array is day
  163.    $mm =$arr[1];                           // second element is date
  164.    $yy =$arr[2];                           // third element is year
  165.    if(!checkdate($dd,$mm,$yy))
  166.    {
  167.     $msg=$msg."You have inputted an invalid valuation date with ".$Date[$i].". <br>";
  168.     $flag="NotOK";
  169.    }
  170.    if(!ereg('[^A-Za-z0-9]', $Staff[$i]))                                                                 // 167
  171.    {
  172.     $msg=$msg."Please enter valid staff names within valuation table. Error with ".$Staff[$i]."<br>";
  173.     $flag="NotOK";
  174.    }
  175.   }
  176.  }
  177.  if(($SubDate!="")|| ($SubDate!=False)||($SubDate!=NULL))
  178.  { 
  179.   for($i=1; $i<=count($SubDate); $i++)
  180.   {
  181.    $arr=split("/",$SubDate[$i]);           // splitting the array
  182.    $dd =$arr[0];                           // first element of the array is day
  183.    $mm =$arr[1];                           // second element is date
  184.    $yy =$arr[2];                           // third element is year
  185.    if(!checkdate($dd,$mm,$yy))
  186.    {
  187.     $msg=$msg."You have inputted an invalid sub date on line ".$i.". <br>";
  188.     $flag="NotOK";
  189.    }
  190.   }
  191.  }
  192.  if(($Staff!="")|| ($Staff!=False)||($Staff!=NULL))
  193.  {
  194.   for($j=1; $j<=count($Staff); $j++)                                              //commented
  195.   {
  196.    if(!ereg('[^A-Za-z0-9]', $Staff[$j]))
  197.    {
  198.     $msg=$msg."Please enter valid staff within variation table <br>";
  199.     $flag="NotOK";
  200.    }
  201.    if(!ereg('[^0-9]', $Hours[$j]))
  202.    {
  203.     $msg=$msg."Please enter valid hours within variation table <br>";
  204.     $flag="NotOK";
  205.    }
  206.   }
  207.  }
  208. }                    //199
  209. function getProjectDetails()
  210. {
  211.  global $ProjName;
  212.   $temp =mysql_query(
  213.              "SELECT   'Float', 'Extension', 'Excusable', 'NonExcusable', 'Delays', 'Value', 'LiquidatedDamages', 'totalLiquidatedDamages' 
  214.               FROM     'ProjectDetails'
  215.               WHERE    'Name'= '$ProjName'" );
  216.   $row = mysql_fetch_array($temp);
  217.   return $row;
  218. }
  219. // A function to allow overall project variables to be manipulated.
  220. function makeVariableProjectDetails()
  221. {
  222.  global $projectFloat, $projectExtension, $projectExcusable, $projectNonExcusable, $projectDelays, $projectValue, $liquidateddamages, $totalliquidateddamages;
  223.  $temp = getProjectDetails(); 
  224.  $projectFloat          = $temp['ProjectFloat'];
  225.  $projectExtension      = $temp['Extension'];
  226.  $projectExcusable      = $temp['Excusable'];
  227.  $projectNonExcusable   = $temp['NonExcusable'];  
  228.  $projectDelays         = $temp['Delays'];
  229.  $projectValue          = $temp['Value'];
  230.  $liquidateddamages     = $temp['LiquidatedDamages'];
  231.  $totalliquidateddamages= $temp['totalLiquidatedDamages'];
  232. }
  233. // A Function to total compensation.
  234. function Compensate()
  235. {
  236.  global $taskValue, $actualValues, $OriginalPrice, $projectTotal, $Hours, $Price, $Wage;
  237.  
  238.  $thevalue=0;
  239.  for($i=1; $i<=count($Hours); $i++)          //This is compensation for actual work
  240.  {
  241.   $actualValues[$i]= $Hours[$i] * $Wage[$i];
  242.   $theValue       += $actualValues;  
  243.  }
  244.  for($j=1; $j<=count($Price); $j++)           //This is compensation for subcontractors / engineers
  245.  {
  246.   $theValue += $Price[$j];
  247.  }  
  248.  $taskValue     = $OriginalPrice-$theValue;
  249.  $projectValues+= $taskValue;                 
  250. }
  251. // Work out if an extension of time is due for total project completion.
  252. function isExtended()                  
  253. {
  254.  global $projectFloat, $AffectCritPath, $projectExtension, $projectExcusable, $projectNonExcusable, $Critical, $Excusable, $Amount, $Amount1, $taskExtension, $totalliquidateddamages, $liquidateddamages; 
  255.  
  256.  $temp=0;
  257.  if ($Excusable =="Yes")
  258.  {
  259.   $taskExtension = $Amount;
  260.  }
  261.  else
  262.  {
  263.   $taskExtension = 0;
  264.  }
  265.  if(($Critical== "No") && ($AffectCritPath== "No"))
  266.  {
  267.   if ($Excusable== "Yes")
  268.   {
  269.    $projectExcusable+= $Amount;
  270.   }
  271.   else
  272.   {
  273.    $projectNonExcusable += $Amount;
  274.   }
  275.  } 
  276.  if($Critical=="Yes")
  277.  {
  278.   $temp = $Amount;
  279.   $continue="Ok";
  280.   if($Excusable =="Yes")
  281.   {
  282.    $projectExcusable += $Amount;
  283.   }
  284.   else
  285.   {
  286.    $projectNonExcusable += $Amount;
  287.   }
  288.  }
  289.  if(($Critical== "No")&&($AffectCritPath== "Yes"))  
  290.  {
  291.   $temp = $Amount1;
  292.   $continue="Ok"; 
  293.   if($Excusable == "Yes")
  294.   {
  295.    $projectExcusable += $Amount1;
  296.   }
  297.   else
  298.   {
  299.    $projectNonExcusable += $Amount1;
  300.   }
  301.  }
  302.  if($continue=="Ok")
  303.  {
  304.   if($projectFloat == "0") 
  305.   {
  306.    $projectExtension      += $temp;
  307.    $totalliquidateddamages+=($liquidateddamages * $temp); 
  308.    $taskExtension          = $temp;
  309.   }
  310.   elseif($projectFloat >= $temp)
  311.   {
  312.    $projectFloat -= $temp;
  313.   }
  314.   else 
  315.   {
  316.    $projectExtension      += ($temp - $projectFloat);
  317.    $totalliquidateddamages+=($liquidateddamages * ($temp-$projectFloat));
  318.    $projectFloat           = 0;
  319.   }
  320.  }
  321. }
  322. //Calculates the difference between two dates
  323. function dateDiff($dformat, $endDate, $beginDate) 
  324. {
  325.  $date_part1=explode($dformat, $beginDate);
  326.  $date_part2=explode($dformat, $endDate);
  327.  $start_date=gregoriantojd($date_parts1[1], $date_parts1[0], $date_parts1[2]);
  328.  $end_date  =gregoriantojd($date_parts2[1], $date_parts2[0], $date_parts2[2]);
  329.  return $end_date - $start_date;
  330. }
  331.  
  332. function numDate($dformat, $date)
  333. {
  334.  $date_part=explode($dformat, $date);
  335.  $numDate=gregoriantojd($date_part[1], $date_part[0], $date_part[2]); 
  336.  return $numDate;
  337. }
  338.  
  339. // A function to find concurrent delays relating to input task
  340. function getDetails($theTask)  
  341. {
  342.  global $ProjName;
  343.  
  344.     $temp    = mysql_query(
  345.            "SELECT   `ProjectName`, `Task`, `Start`,`End`,`Excusable`, `Amount`, `CDelay1`, `CDelay2` 
  346.             FROM     `Delay`
  347.             WHERE    `ProjectName`= `$ProjName`
  348.             AND      `Delay.Task` = `Concurrent.Task`
  349.             AND      `Task` = `$theTask`
  350.             ASC" );
  351.   $row = mysql_fetch_array($temp);
  352.   return $row;
  353. }
  354.  
  355.  
  356. // A function to determine connected delays to current delay
  357. function getAllRelCons() 
  358. {
  359.  global $CDelay1, $CDelay2, $conNum1, $conNum2;
  360.  $i=0;
  361.  $count=1;
  362.  
  363.  $conNum[$i][1] = $CDelay1;
  364.  $conNum[$i][2] = $CDelay2;
  365.  $more1 = getDetails($CDelay1);
  366.  $more2 = getDetails($CDelay2);
  367.  for($i=1; $i<=$count; $i++)
  368.  {                                                 
  369.    if($more1['CDelay1']!="FALSE")
  370.    {
  371.     $count += 1;
  372.     $conNum[$count][1] = $more1['CDelay1'];
  373.     $more1=getDetails($more1['CDelay1']);            
  374.    }
  375.  
  376.    if($more1['CDelay2']!="FALSE")                   // Check 2nd Delay
  377.    {
  378.     $conNum[$count][2] = $more1['CDelay2'];
  379.     $more1=getDetails($more1['CDelay2']);
  380.    }
  381.  
  382.    if($more2['CDelay1']!="FALSE")
  383.    {
  384.     $count += 1;
  385.     $conNum[$count][1] = $more2['CDelay1'];
  386.     $more2=getDetails($more2['CDelay1']);
  387.    }
  388.  
  389.    if($more2['CDelay2']!="FALSE")
  390.    {
  391.     $conNum[$count][2] = $more2['CDelay2'];
  392.     $more2=getDetails($more2['CDelay2']);
  393.    }
  394.  }
  395.  
  396. function getActualValuations($taskName)
  397. {
  398.  global $ProjName;
  399.  $temp =mysql_query(
  400.              "SELECT   'Date', 'Staff', 'actualValues' 
  401.               FROM     'ValuationActual'
  402.               WHERE    'ProjectName'= '$ProjName'
  403.           AND      'Task'       = '$taskName'
  404.               ASC" );
  405.   $row = mysql_fetch_array($temp);
  406.   return $row;
  407. }
  408.  
  409. function getSubValues($taskName)
  410. {
  411.  global $ProjName;
  412.   $temp =mysql_query(
  413.              "SELECT   'Date', 'Staff', 'Price' 
  414.               FROM     'ValuationSubs'
  415.               WHERE    'ProjectName'= '$ProjName'
  416.           AND      'Task'       = '$taskName'
  417.               ASC" );
  418.   $row = mysql_fetch_array($temp);
  419.   return $row;
  420. }
  421.  
  422. function modify($theDate, $theStaff)
  423. {
  424.  global $ProjName;
  425.  
  426.  mysql_query(
  427.    "UPDATE ValuationActual
  428.     SET    Removed     = 'Yes' 
  429.     WHERE  ProjectName = $ProjName
  430.     AND    Date        = $theDate
  431.     AND    Staff       = $theStaff");
  432. }
  433.  
  434. function modifySubs($theDate, $theStaff)
  435. {
  436.  global $ProjName;
  437.  
  438.  mysql_query(
  439.    "UPDATE ValuationSubs
  440.     SET    Removed     = Yes 
  441.     WHERE  ProjectName = $ProjName
  442.     AND    Date        = $theDate
  443.     AND    Subs        = $theStaff");
  444. }
  445.  
  446. function removeValueTotals()
  447. {
  448.  global $removingActual, $removingSub, $taskValue, $projectValue, $valueReduction;
  449.  $tempTotal = 0;
  450.  $tempTotal1=0;
  451.  
  452.  for($i=1; $i<=count($removingActual); $i++)
  453.  {
  454.   modify($removingActual[$i]['Date'], $removingActual[$i]['Staff']);
  455.   $tempTotal += $removingActual[$i]['actualValue'];
  456.  }
  457.  for($i=1; $i<=count($removingSub); $i++)
  458.  {
  459.   modifysubs($removingSub[$i]['Date'], $removingSub[$i]['Subs']);
  460.   $tempTotal1 += $removingSub[$i]['Price'];
  461.  }
  462.  $valueReduction = $projectValue - ($tempTotal + $tempTotal1);
  463.  $projectValue  -=($tempTotal + $tempTotal1);
  464. }
  465.  
  466. function findValuations($taskName, $theStartDate, $theEndDate, $isActualRSub)
  467. {
  468.  global $removingActual, $removingSub, $actualValues, $subValues;
  469.  $count=1;
  470.  $i    =0;
  471.  $startFlagged = "No";
  472.  $endFlagged   = "No";
  473.  if($isActualRSub=="Actual")
  474.  {
  475.   $tempValues = getActualValuations($taskName);
  476.   $num        = mysql_num_rows($result);
  477.  }
  478.  else                                            
  479.  {
  480.   $tempValues = getSubvalues($taskName);
  481.   $num        = mysql_num_rows($result);      
  482.  }
  483.  for($i=1; $i<=$num; $i++)                               // While statement I think this for has to be placed above 1st if
  484.  {
  485.   if(($startFlagged!="Yes") && ($endFlagged!="yes"))     // find the record with start date
  486.   {
  487.    if(($startFlagged == "Yes") && ($endFlagged!="yes"))  // check record between start and end
  488.    {
  489.     if($actualValues[$i]['Date']==$theEndDate)             // check if record equals end date
  490.     {
  491.      if($actualValues[$i+1]['Date'] !=$theEndDate)      // check whether it is last end date
  492.      {
  493.       $endFlagged = "Yes";                               // flag last end date record
  494.      }
  495.     }
  496.     if($isActualRSub=="Actual")
  497.     {
  498.      $removingActual[$count] = $tempValues[$i];
  499.     }
  500.     else
  501.     {
  502.      $removingSub[$count] = $tempValues[$i];
  503.     }
  504.     $count += 1;
  505.    }
  506.    else 
  507.    {
  508.     if($actualValues[$i]['Date'] == $theStartDate)
  509.     {
  510.      if($isActualRSub=="Actual")
  511.      {
  512.       $removingActual[$count] = $tempValues[$i];      // check this
  513.      }
  514.      else
  515.      {
  516.       $removingSub[$count] = $tempValues[$i];
  517.      }
  518.      $count +=1;
  519.      if($startflagged != "Yes")                          // test whether it has been flagged?
  520.      {
  521.       $startflagged = "Yes";                                // flag start of values to be disregarded
  522.      }
  523.     }
  524.    }
  525.   }
  526.  }
  527. }
  528.  
  529. function findInputValues($theStart, $theEnd, $actualRSub)
  530. {
  531.  global $Staff, $Subs, $taskValue, $actualValues, $actualRemoved, $subRemoved;
  532.  $startFlagged = "No";
  533.  $endFlagged = "No";
  534.  
  535.  if($actualRSub == "Actual")                  // the mysql fetch array needs to be inside loop
  536.  {
  537.   for($i=1; $i<=count($Staff); $i++)
  538.   {
  539.    $temp[$i] = $Staff[$i];
  540.   }
  541.  }
  542.  else
  543.  {
  544.   for($i=1; $i<=count($Subs); $i++)
  545.   {
  546.    $temp[$i] = $Subs[$i];
  547.   }
  548.  }
  549.  for($i=1; $i<=count($temp); $i++)
  550.  {
  551.   if(($startFlagged!="Yes") && ($endFlagged!="yes"))
  552.   {
  553.    if(($startFlagged == "Yes") && ($endFlagged!="yes"))
  554.    {
  555.     if($temp[$i]==$theEndDate)
  556.     {
  557.      if($temp[$i+1] !=$theEndDate)          
  558.      {
  559.       $endFlagged = "Yes";                               
  560.      }
  561.     }
  562.     if($actualRSub=="Actual")
  563.     {
  564.      $taskValue       -= $actualValues[$i];
  565.      $projectValue    -= $actualValues[$i];
  566.      $actualRemoved[$i]= "Yes"; 
  567.     }
  568.     else
  569.     {
  570.      $taskValue    -= $Price[$i];
  571.      $projectValue -= $Price[$i];
  572.      $subRemoved[$i]= "Yes";
  573.     }
  574.    }
  575.    else
  576.    {
  577.     if($temp[$i] == $theStartDate)
  578.     {
  579.      if($isActualRSub=="Actual")
  580.      {
  581.      $taskvalue       -= $actualvalues[$i];
  582.      $projectValue    -= $actualValue[$i];
  583.      $actualRemoved[$i]= "Yes";
  584.      }
  585.      else
  586.      {
  587.       $taskValue    -= $Price[$i];
  588.       $projectValue -= $Price[$i];
  589.       $subRemoved[$i]= "Yes";
  590.      }
  591.      if($startflagged != "Yes")                     // test whether it has been flagged?
  592.      {
  593.           $startflagged = "Yes";                        // flag start of values to be disregarded
  594.      }
  595.      }
  596.    }
  597.   }
  598.  }
  599. }
  600.  
  601. // A function to check concurrency. Concurrency is when there is an excusable and non excusable    
  602. function isConcurrency()  
  603. {
  604.  global $Amount, $Amount1, $ConcurrentDelay, $ProjectExtension, $ProjectExcusable,$ProjectNonExcusable, $dontAdd;
  605.  
  606.  $temp   = getDetails($ConcurrentDelay);
  607.  if (($Crit=="No")&&($AffectCritPath=="Yes"))  
  608.  {
  609.   $temp1 = $Amount1;
  610.  }
  611.  else if(($temp['Critical']=="No") && ($temp['AffectCritPath']=="Yes"))
  612.  {
  613.   $temp2 = $temp['Amount1'];
  614.  }
  615.  else
  616.  {
  617.   $temp1 = $Amount;
  618.   $temp2 = $Amount1;
  619.  } 
  620.  $ATotal = dateDiff('/', $End, $Start);
  621.  $BTotal = dateDiff('/', $temp['End'], $temp['Start']);
  622.  $AStart = numDate('/', $End)-$temp1;
  623.  $BStart = numDate('/', $temp['End'])-$temp2;
  624.  $temp3  = $AStart - $BStart;
  625.  if($temp3 >=0)
  626.  {
  627.   if(($BTotal + $temp3) >= $ATotal) 
  628.   {
  629.    if(($Excusable=="Yes") && ($temp['Excusable'] =="No"))
  630.    {
  631.     findInputValues($Start, $End, 'Actual');
  632.     findInputvalues($Start, $End, 'Sub');
  633.    }
  634.    if(($Excusable=="No") && ($temp['Excusable'] =="Yes"))  
  635.    {
  636.     findValuations($ConcurrentDelay, $Start, $End, "Actual");
  637.     findValuations($ConcurrentDelay, $Start, $End, "Sub");
  638.     removeValueTotals();
  639.    }
  640.   }
  641.   else
  642.   {
  643.    $temp4 = dateDiff('/', $temp['End'], $Start);
  644.    if(($Excusable=="Yes") && ($temp['Excusable'] =="No"))
  645.    {
  646.     removeInputValuations($Task, $Start, $temp['End']);
  647.    }
  648.    if(($Excusable=="No") && ($temp['Excusable'] =="Yes"))  
  649.    {
  650.     findValuations($ConcurrentDelay, $Start, $temp['End'], 'Actual');
  651.     findValuations($ConcurrentDelay, $Start, $temp['End'], 'Sub');
  652.     removeValueTotals();
  653.    }
  654.   }
  655.  }
  656.  else
  657.  {
  658.   $temp3 = $temp3 * (-1);
  659.   $temp4 = dateDiff('/', $End, $temp['Start']);
  660.   if(($BTotal - $temp3) >= $ATotal)             
  661.   {
  662.    if(($Excusable=="Yes") && ($temp['Excusable'] =="No"))
  663.    {
  664.     findInputValues($temp['Start'], $End, "Actual");
  665.     findInputvalues($temp['Start'], $End, "Sub");
  666.    }
  667.    if(($Excusable=="No") && ($temp['Excusable'] =="Yes"))  
  668.    {
  669.     removeValuations($ConcurrentDelay, $temp['Start'], $End, "Actual");
  670.     removeValuations($ConcurrentDelay, $temp['Start'], $End, "Subs");
  671.     removeValueTotals();
  672.    }
  673.   }
  674.   else
  675.   {
  676.    if(($Excusable=="Yes") && ($temp['Excusable'] =="No"))
  677.    {
  678.     removeInputValuations($Task, $temp['Start'], $temp['End']);
  679.    }
  680.    if(($Excusable=="No") && ($temp['Excusable'] =="Yes"))  
  681.    {
  682.     removeValuations($ConcurrentDelay, $temp['Start'], $temp['End'], 'Actual');
  683.     removeValuations($ConcurrentDelay, $temp['Start'], $temp['End'], 'Sub');
  684.     removeValueTotals();
  685.    }
  686.   }
  687.  }
  688. }
  689.  
  690. // A function to update the project details 
  691. function updateProjectDetails()
  692. {
  693.  global $ProjName, $projectFloat, $projectExtension, $projectExcusable, $projectNonExcusable,$projectDelays, $projectValue;
  694.  
  695.  mysql_query(
  696.    "UPDATE ProjectDetails
  697.     SET    ProjectFloat          = $projectFloat
  698.        Extension             = $projectExtension
  699.        Excusable             = $projectExcusable
  700.            NonExcusable          = $projectNonExcusable
  701.        Delays                = $projectDelays
  702.        Value                 = $projectValue
  703.        LiquidatedDamages     = $liquidatedDamages
  704.            totalLiquidatedDamages= $totalLiquidatedDamages
  705.     WHERE  Name       = $ProjName");
  706. }
  707.  
  708. // A function to insert a new record into task details table
  709. function insertTaskDetails()
  710. {
  711.  global $taskExtension, $taskValue;
  712.  mysql_query(
  713.     "INSERT INTO Delay 
  714.     (ProjectName, Task, Start, End, Extension, Value, OriginalPrice,  Excusable, Critical, AffectCritPath, Amount, Variation, Concurrent, Design, Reason, Proof, Mitigation, Comments) 
  715.      VALUES
  716.        ('$_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])");
  717. }
  718.  
  719. // A function to insert a new record into concurrent delays table
  720. function insertConcurrent()
  721. {
  722.  mysql_query(
  723.     "INSERT INTO ConcurrentDelays
  724.        ( ProjectName, Task, ConcurrentDelay, ValueReduction)
  725.      VALUES
  726.        ( '$_POST[ProjName]', '$_POST[Task]', '$_POST[ConcurrentDelay]', '$valueReduction' )");
  727. }       
  728.  
  729. // A function to insert a new record into emails table
  730. function insertEmail($from, $to, $date, $subject, $message)
  731. {
  732.  mysql_query(
  733.     "INSERT INTO Email
  734.        ( ProjectName, Task, EmailFrom, EmailTo, Date, Subject, Message)
  735.      VALUES
  736.        ( '$_POST[EmailProjName]', '$_POST[EmailTask]', '$EmailFrom', '$EmailTo', '$EmailDate', '$EmailSubject', '$EmailMessage' )");
  737. }       
  738.  
  739. // A function to insert a new record into ValuationActual table
  740. function insertValuationActual($theDate, $theStaff, $theWage, $theHours, $theActualValues, $theActualRemoved)
  741. {
  742.  mysql_query(
  743.     "INSERT INTO ValuationActual
  744.        ( ProjectName, Task, Date, Staff, Wage, Hours, Value, Removed)
  745.      VALUES
  746.        ( '$_POST[ProjName]', '$_POST[Task]', '$theDate', '$theStaff', '$theWage', '$theHours', '$theActualValues', '$theActualRemoved' )");
  747. }
  748.  
  749. // A function to insert a new record into Valuation (Subcontractors / Engineers) table
  750. function insertValuationSubs($theDate, $theSubs, $theType, $thePrice, $theSubRemoved)
  751. {
  752.  mysql_query(
  753.     "INSERT INTO ValuationSubs
  754.        ( ProjectName, Task, Date, SubContractor, Type, Price, Removed)
  755.      VALUES
  756.        ( '$_POST[ProjName]', '$_POST[Task]', '$theDate', '$theSubs', '$theType', '$thePrice',  '$theSubRemoved' )");
  757. }
  758.  
  759. // A function to insert a new record into ConnectedDelays
  760. function insertConnectedDelay()
  761. {
  762.  mysql_query(
  763.     "INSERT INTO ConnectedDelays
  764.        ( ProjectName, Task, ConnectedDelay1, ConnectedDelay2 )
  765.      VALUES
  766.        ( '$_POST[ProjName]', '$_POST[Task]', '$_POST[CDelay2]', '$_POST[CDelay1]' )");
  767. }
  768. // The order of the functions to be called to process the delay.
  769. validate();
  770. if($flag=="OK")
  771. {
  772.  makeVariableProjectDetails();
  773.  Compensate();
  774.  isExtended();
  775.  if(($CDelay1!="")|| ($CDelay1!=False)||($CDelay1!=NULL))
  776.  {
  777.   getAllRelCons();
  778.  }
  779.  if($concurrent =="Yes")
  780.  {
  781.   isConcurrency();
  782.   insertConcurrent;
  783.  }
  784.  updateProjectDetails();
  785.  insertTaskDetails();
  786.  if(($EmailDate!="")|| ($EmailDate!=False)||($EmailDate!=NULL))
  787.  {
  788.   for($i=1; $i<=count($EmailFrom); $i++)
  789.   {
  790.    insertEmail($EmailFrom[$i], $EmailTo[$i], $EmailDate[$i], $EmailSubject[$i], $EmailMessage[$i]);
  791.   }
  792.  }
  793.  if(($Date!="")|| ($Date!=False)||($Date!=NULL))
  794.  {
  795.   for($i=1; $i<=count($Date); $i++)
  796.   {
  797.    insertValuationActual($Date[$i], $Staff[$i], $Wage[$i], $Hours[$i], $actualValues[$i],  $actualRemoved[$i]);
  798.   }
  799.  }
  800.  if(($SubDate!="")|| ($SubDate!=False)||($SubDate!=NULL))
  801.  {
  802.   for($i=1; $i<=count($SubDate); $i++)
  803.   {
  804.    insertValuationSubs($SubDate[$i], $Subs[$i], $Price[$i], $subRemoved[$i]); 
  805.   }
  806.  }
  807.  insertConnectedDelay();
  808. }
  809. else
  810. {
  811.  echo $msg;
  812.  echo "hello";
  813. }
  814. ?>
  815. </html>
  816.  
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 :)
Oct 3 '08 #6

code green
Expert 100+
P: 1,726
Sorry for late reply. But away at weekend
I dumped your code in a debugger which reported this syntax error.
Expand|Select|Wrap|Line Numbers
  1. Fatal error: Function name must be a string in .............
  2.  ...........php on line 66
You have used round brackets instead of square[PHP]66. $SubDate=$_POST('SubDate[]'); [/PHP]
same here [PHP]$PlantDate =$_POST('PlantDate[]');
$Plant =$_POST('Plant[]');
$PlantType =$_POST('PlantType[]');
$PlantCharge=$_POST('PlantCharge[]');
$PlantDays =$_POST('PlantDays[]');[/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
Oct 6 '08 #7

P: 36
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!
Oct 6 '08 #8

Markus
Expert 5K+
P: 6,050
If you have a good IDE, like PHPDesigner, it will have a built in debugger that you can run on your code.

Mark.
Oct 6 '08 #9

code green
Expert 100+
P: 1,726
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('display_errors',1);
ini_set('display_startup_errors ',1);[/PHP] Can't remember what they all do but give it a try.
Oct 6 '08 #10

P: 36
sound 1 both of you for helping a newb to php like me. It is appreciated.
Oct 6 '08 #11

Markus
Expert 5K+
P: 6,050
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.
Oct 6 '08 #12

P: 36
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...
Oct 8 '08 #13

pbmods
Expert 5K+
P: 5,821
Heya, Micky.

What is the code on line 250?
Oct 9 '08 #14

P: 36
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(relating 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.
Oct 9 '08 #15

P: 36
sorry guys i found what the problem was and i feel like a rite plonker...

I have been frustrated with this software so i decided to begin from scratch and add sections of code at a time when i noticed that the error was still on 166 and i only had 60. I checked the error again and low and behold the error says input.html not the mainphp.php.

I was a day away from smashing the computer but ill take her back now :D
Oct 9 '08 #16

Post your reply

Sign in to post your reply or Sign up for a free account.