Link to home
Start Free TrialLog in
Avatar of h3rm1t9536
h3rm1t9536

asked on

PHP syntax error T_CONSTANT_ENCAPSED_STRING

Hi All,

I have a PHP site that displays reports from stored procedures in SQL. I use a dev to do the site work for me and after a change the site is not working.

The error that now comes up is

 Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in D:\inetpub\wwwroot\reporting\src\php\reports.php on line 331

Line 331 of reports.php reads.

report->DaysOverdue = '<span style="color: green;">'.$report->DaysOverdue-30.'</span>';

The dev added a function to remove 30 from the value of the results in this column. I suspect that's whats broken it but I can't get hold of him for a few days so any help would be appreciated.

Thanks

H
Avatar of Radek Baranowski
Radek Baranowski
Flag of Poland image

escape the quotes:

report->DaysOverdue = '<span style=\"color: green;\">'.$report->DaysOverdue-30.'</span>';
Avatar of h3rm1t9536
h3rm1t9536

ASKER

Hi Radek,

So to be clear (remember I have no knowledge of PHP !) I'm simply adding a \ in two places?
OK. Tried that, same error unfortunately.
aaah, no
 sorry
you just omiited $ at the beginning. forget the slashes.

$report->DaysOverdue = '<span style="color: green;">'.$report->DaysOverdue-30.'</span>';
Apologies, it does have a $ at the beginning already. I somehow didn't paste that in.
ASKER CERTIFIED SOLUTION
Avatar of Radek Baranowski
Radek Baranowski
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
did it help ?
I am having to wait for a dev to look at that as its beyond my capabilities. I will feedback as soon as its been tried.
You need a professional PHP developer to help you here.  The "quick change" your developer provided should have been tested, and obviously was not.  My guess is that you have a requirement for more than one line of changes.  The PHP parser will stop after the first parse error.  If the "quick change" involved more than one line, there may be more than one error!

I would consider this step as a way to start the testing process (but it's a process, and may require more than one step).  And this step "mungs" the DaysOverdue property in the $report object, so it's a patch but may have downstream effects that we cannot know by looking at one line of PHP code.

$x = $report->DaysOverdue - 30;
$report->DaysOverdue = '<span style="color: green;">' . $x . '</span>';
A developer solved it in the end.

$report->DaysOverdue = '<span style="color: green;">'.($report->DaysOverdue-30).'</span>';

Thanks for the help.
well it sounds like exactly mine solution but it's your call ofkz :D