syntax error, unexpected T_STRING in php [closed] - php

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
Hi I am getting this error and it has become a headache for me. Can anyone please help me where I have committed mistake.
Here is my code.
<?php echo mxp_draw_pull_down_menu('datefield', MxpStatistics::getFieldsDropDown(), isset($_SESSION['statistics']['datefield']) ? $_SESSION['statistics']['datefield'] : ' ', 'onchange="javascript: saveModify(document.searchreport'.$rand.', \''.mxp_href_link_admin(FILENAME_DEFAULT, $MxpTemplate->getModule() . '&module=' . substr($file['name'], 0, strrpos($file['name'], '.'))) ."' , null, " . $_GET['windowId']);"');?>

Just remove last four characters("');) from your code.
You can detect you syntax errors easily, if you use any syntax highlighting IDE.
Also, if you try to save number of line like this, it will be a real headache for you to find syntax errors and debug.
Try this code
<?php
echo mxp_draw_pull_down_menu('datefield', MxpStatistics::getFieldsDropDown(), isset($_SESSION['statistics']['datefield']) ? $_SESSION['statistics']['datefield'] : ' ', 'onchange="javascript: saveModify(document.searchreport'.$rand.', \''.mxp_href_link_admin(FILENAME_DEFAULT, $MxpTemplate->getModule() . '&module=' . substr($file['name'], 0, strrpos($file['name'], '.'))) ."' , null, " . $_GET['windowId']);
?>

Related

My code is not working ($h.= ') [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
Can anyone help me for this why doesn't my code work?
$h.= ' 'mysql_result($res,$z,"name")'';
It gives me an error because of the <a href
$h .= ''.mysql_result($res,$z,"name").'';
Should work now
. before mysql_result and after.
Also take a look here it will help you to understand String Operators and etc.
You need to concatenate.
$h.= ' ' . mysql_result($res,$z,"name") . '';
Anyway, I would suggest you to put mysql_result($res,$z,"name") into a variable, to increase readability and avoid executing the function every time you call it.
I mean:
$name = mysql_result($res,$z,"name");
$h.= ' ' . $name . '';
Try this
$h.= ''.mysql_result($res,$z,"name").'';
You are missing . the concatenation operator

Parsing Text And Two Variables, PHP [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I have a question on parsing this line of php code. I've tried but cant get it, I have also searched tons of forums but could not find the right thing. Could someone help?
$message = "CheckSMS= . $_POST['number'] . "=" . $_POST['message'];
In the end it should look like this: CheckSMS=number=message
The syntax highlighting shows your errors, you're missing the closing " on the first one.
$message = "CheckSMS= . $_POST['number'] . "=" . $_POST['message'];
Should be:
$message = "CheckSMS=" . $_POST['number'] . "=" . $_POST['message'];
You should probably also do some input validation and so on, because you can't fully ever trust a POST variable, etc, but this solves this problem.
There's several ways to do this:
// Complex (curly) syntax
$message = "CheckSMS={$_POST['number']}={$_POST['message']}";
// Concatenation
$message = "CheckSMS=".$_POST['number']."=".$_POST['message'];
// sprintf()
$message = sprintf("CheckSMS=%s=%s", $_POST['number'], $_POST['message']);

Getting Parse Error While Using Two Functions [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I am trying to write a program using Call By Reference to calculate the area but I am getting a Parse Error :-
Parse error: syntax error, unexpected 'ar' (T_STRING) in C:\xampp\htdocs\workspace.php on line 7
Now I, cannot think why it is happening?
<?php
function perimeter(&$l,&$b,&$result)
{
$result=2*($l+$b);
}
funtction ar(&$le,&$br,&$result1)
{
$result1=$le*$br;
}
$result=1;
$length=$_GET['length'];
$breadth=$_GET['breadth'];
echo "<h1><center>Area And Perimeter Calculator Using Call By Reference</h1></center>";
$result = perimeter($length,$breadth,$result);
echo "<br />The Perimeter Of The Rectangle Is <strong>$result</strong>";
$result= ar($length,$breadth,$result);
echo "<br /><br />The Area Of The Rectangle Is = <strong>$result</strong>";
?>
You misspelled function:
funtction ar(&$le,&$br,&$result1)
{
$result1=$le*$br;
}
should be
function ar(&$le,&$br,&$result1)
{
$result1=$le*$br;
}

Syntax error, unexpected T_OBJECT_OPERATOR? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
PHP Parse error: syntax error, unexpected T_OBJECT_OPERATOR in ...
tpl->set( '[complaint]', "<a href=\"javascript:AddComplaint('" . $row['id'] . "', 'comments')\">" );
What in this code causing problem, please help to find answer.
You're missing the dollar sign before your variable name:
tpl->set( '[complaint]', "<a href=\"javascript:AddComplaint('" . $row['id'] . "', 'comments')\">" );
should be:
$tpl->set( '[complaint]', "<a href=\"javascript:AddComplaint('" . $row['id'] . "', 'comments')\">" );

echo out valuename in php [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 years ago.
Improve this question
how can I print out a variable name in text in php?
I want to accomplish something as simple as having this:
echo "|" . "$myvariable" . "|";
print out this:
|$myvariable|
instead of this:
||
how can I accomplish this?
Use single quotes so that the variables don't get interpolated:
echo "|" . '$myvariable' . "|";
As others pointed out, use single quotes to show the variable name "as is".
echo "|" . '$myvariable' . "|";
Be sure to read this part of the manual.

Categories