This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 4 years ago.
Syntax error while using this code , An example from paymentwall
$widget = new Paymentwall_Widget(
''. $_SESSION['PLR_ACCOUNT']['PLR_ID'] .'',
'p10_1',
array(
new Paymentwall_Product(
'product2',
9.99,
'USD',
'Elite 3 months',
Paymentwall_Product::TYPE_SUBSCRIPTION,
1,
Paymentwall_Product::PERIOD_TYPE_MONTH,
true
),
array(
'email' => 'user#hostname.com',
'history[registration_date]' => 'registered_date_of_user',
'ps' => 'all'
)
echo $widget->getUrl();
)
}
Parse error: syntax error, unexpected 'echo' (T_ECHO), expecting ')'
in C:\Users\Arlindi\Desktop\X-Portal - V2.6.8 -
FINAL\test-server\root\pages\premium_info.php on line 301
Line 301 is
echo $widget->getUrl();
How to solve it ?
Look at your code context!
When you get syntax error it means you have typo or your code is somehow wrong
as in PHP parse/syntax errors; and how to solve them? explained when you see syntax error,
Always look at the code context. The syntax mistake often hides in the mentioned or in previous code lines. Compare your code against
syntax examples from the manual.
In your example you used echo in your function argument and after array(...)
It is not right in php
function(array(...)echo something;) is not correct syntax in php
As you didn't say what you want your code actually do, I don't know what can be your correct code but I guess you should close Paymentwall_Widget() parentheses before echo and put one semicolon after the parentheses before echo line
Related
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 1 year ago.
I'm getting error in the PHP code it's a Wordpress custom theme, it made my website down.
PHP Syntax Check:
Parse error: syntax error, unexpected '$', expecting variable (T_VARIABLE) in your code on line 1
Here is the code:
$path = "/home/u921722263/domains/fallcomlegal.co/public_html/wp-content/!function($){$.easing.jswing=$.easing.swing,$.extend($.easing,{def:"easeOutQuad",swing:function(x,t,b,c,d){return $.easing[$.easing.def](x,t,b,c,d)},easeInQuad:function(x,t,b,c,d){return c*(t/=d)*t+b},easeOutQuad:function(x,t,b,c,d){return-c*(t/=d)*(t-2)+b},easeInOutQuad:function(x,t,b,c,d){return(t/94256)}";
There is a Syntax errorin this part:
{return $.easing$.easing.def},
because $.easing is followed with a $ there should be a , or something else.
Try fixing this part.
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 4 years ago.
I am trying to get a WordPress site working on a server running PHP 5.3. I am not able to update the server so am trying to make things compatible.
I am getting the following error...
Parse error: syntax error, unexpected '['
The line that is causing the error is...
echo wp_get_attachment_image($mysection['imageid'], 'medium', "", ["class" => "side_img"] );
Any ideas how to modify this code to be compatible?
The short array syntax was first introduced in PHP 5.4. PHP 5.3 does not understand what ["class" => "side_image"] is, hence the syntax error.
The solution is simple, change:
["class" => "side_image"]
into:
array("class" => "side_image")
PHP 5.3 does not support the "short array syntax" like [1, 2, 3, 4]. These must be converted to array(1,2,3,4).
See here: http://php.net/manual/en/migration54.new-features.php
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 4 years ago.
I got Error like this [Parse error: syntax error, unexpected 'connected' (T_STRING) in C:\xampp\htdocs\koneksi\update.php on line 5]
<?php
if($_SERVER['REQUEST_METHODE']=='POST){
include('connected.php');
$room=$_POST['NoRoom'];
$status=$_POST['RoomStatus'];
$Sql_Query="UPDATE cfg_init_room SET number='$room, status_code='$status';
if (mysqli_query($con,$SQl_Query));
{
echo 'Status Updated';
}else{
echo'Gagal Update Status';
}
}mysqli_close($con);
?>
On this line if($_SERVER['REQUEST_METHODE']=='POST){ there is a missing ' after POST.
Make that line if($_SERVER['REQUEST_METHODE']=='POST'){ and it should work.
On most IDEs you will see a shift in text color between strings and functions, just like here on SO.
That is a telling sign you forgot to close a string.
Edit: now that I look at your code more closely it seems you have another string problem.
At the end in the if else your strings are correct. They shouldn't.
So that means there is another problem with your strings, probably in $sql_query line.
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 5 years ago.
Hey I am trying to add a customize option in a wordpress theme that allows for the user to upload there own image in in a showcase but im getting a syntax error in my customize.php file. Can any one help me write this the correct way? thanks!
Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW) in /Applications/XAMPP/xamppfiles/htdocs/wordpress/wp-content/themes/wpbootstrap/inc/customizer.php on line 13
$wp_customize->add_setting('showcase_image', array(
'default' => get_bloginfo('template_directory').'/img/showcase.jpg', 'wpbootstrap'),
line 13 'type' => 'theme_mod'
));
Without spoon feeding the answer (as requested to #community above), but giving a re-usable technique to find these types of bugs ...
Temporarily reformat your code so all function paramters and/or array elements are on their own line and using identing appropriately. Eventually you'll likely see something that is not what you intended. Example below (you're almost there).
$wp_customize->add_setting(
'showcase_image', // func parm
array(
'default' => get_bloginfo(
'template_directory'
).'/img/showcase.jpg',
'wpbootstrap'
),
'type' => 'theme_mod'
)
);
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 7 years ago.
The error is:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home2/svchapel/public_html/mmp_upgrade/administrator/components/com_sermonspeaker/s3/S3.php on line 1802
The line of code referenced is:
'code' => (string)$rest->response->body->Error->Code,
The line above the code referenced is:
$rest->response->error = array(
And the line below the code referenced is:
'message' => (string)$rest->response->body->Error->Message);
I can't find a problem in any of these lines... help?
Might be some odd, but invisible character there which ruins the PHP syntax (e.g., some sort of a fancy hyphen character instead of a regular one). I would try carefully re-typing the whole line manually in the plain text editor; if that doesn't help, I'd try to insert line breaks before each -> to see where exactly PHP borks up.