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 7 years ago.
Improve this question
I have this code:
?php
if ( is_page('1708')) {
<div id="portofoliu"></div>
}
?>
And this my error:
Parse error: syntax error, unexpected '<' in /home/dacproie/public_html/eventos/wp-content/themes/eventos/header.php on line 141
What is wrong in this code?
Can you help me to solve this problem please?
Thanks in advance!
Missing echo:
<?php
if ( is_page('1708')) {
echo '<div id="portofoliu"></div>';
}
?>
You can't mix HTML and PHP this way.
Another option is (for longer HTML code):
<?php
if ( is_page('1708')) {
?>
<div id="portofoliu"></div>
<?php
}
?>
OR
<?php
if ( is_page('1708')) :
?>
<div id="portofoliu"></div>
<?php
endif;
?>
And, of course, PHP begins with <?php but it seems to be just copy&paste error.
Might seem obvious but... You need to escape your html to be a string. Otherwise PHP trys to execute it.
<?php
if ( is_page('1708')) {
echo '<div id="portofoliu"></div>';
}
?>
You forgot to close and open PHP tags:
<?php
if ( is_page('1708')) {
?>
<div id="portofoliu"></div>
<?php
}
?>
try
<?php
if ( is_page('1708')) {
echo '<div id="portofoliu"></div>';
}
?>
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
i wanna test if my variable is empty or not to display some differents things.
When i don't use the else...if everything work but when i use this code :
<?php
$Amazon = get_post_meta($post->ID, "Lien Amazon", true);
?>
<?php
if( $Amazon != NULL ){
echo '<li><span class="post-meta-key">Acheter sur Amazon</li>' ;}
else {
echo '<li><span class="post-meta-key">Acheter sur Amazon</li>' ;}
?>
What is the problem ? Thank you
Here is an output error. You haven't closed and reopened the string on trying to concat a variable.
echo '<li><span class="post-meta-key">Acheter sur Amazon</li>' ;
Do instead:
echo '<li><span class="post-meta-key">Acheter sur Amazon</li>' ;
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
<?php for($x = 0; $x <= count($slides); $x++):?>
<li data-target="#main-carousel" data-slide-to="<?php echo($x);?>'" class="active"></li>
<?php endforeach; ?>
Not exactly sure what the error is everything seems right.
You start yourself with a for loop, while closing it with a foreach loop. These are two very different things and cannot be matched like that.
You simply need to replace
<?php endforeach; ?>
with
<?php endfor; ?>
Alternatively, you can use curlybrackets { instead, having something like
<?php for($x = 0; $x <= count($slides); $x++) { ?>
<!-- do HTML here -->
<?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
Parse error: syntax error, unexpected T_DOUBLE_ARROW
i am a beginner at best when it comes to php
below is the code
<?php endwhile; wp_reset_query(); ?>
<?php $mytrails = new WP_Querry)
'post_type' => '$mytrails'
)); ?>
<?php while($mytrails->have_posts()) : $mytrails->the_post();?>
<div class="large-6 columns">
<div class="panel">
<div class="thumbtitle group">
<div class="thumbnail">
<?php the_post_thumbnail('thumbnail');?>
Replace:
<?php $mytrails = new WP_Querry)
'post_type' => '$mytrails'
)); ?>
With:
<?php $mytrails = new WP_Query( array(
'post_type' => $mytrails
) ); ?>
In your version there's a typo in WP_Query, a missing array, a closing bracket where there shouldn't be one, and a variable inside single quotes.
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'm trying to display a "log in" / "log out" link. I want to display the log in link if they are not logged in, etc. I'm having trouble getting this to work. Heres what I've been trying:
<?php if (isset($_SESSION['access_token']))
{ ?> Log out<?php } ?>
<?php
else
{ ?> Log In <?php } ?>
Basically, if the assess_token is set, it will show a link to log out. And if not, a log in link. I keep getting this as an error:
Parse error: syntax error, unexpected T_ELSE
And i've tried this variation:
<?php if (isset($_SESSION['access_token']))
{ echo "Log out" }
else
{ echo "Log In" } ?>
which get me:
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'
what am i missing here?
You have 2 examples and both have syntax errors:
Parse error: syntax error, unexpected T_ELSE
If you format your code correctly, you found the error:
<?php
if (isset($_SESSION['access_token'])) {
?> Log out<?php
} else {
?> Log In <?php
}
?>
That:
<?php } ?>
<?php
else
{ ?>
is not valid. The PHP intepreter can't handle this! Please use <?php } else { ?>
The second: Use an Syntax-Highlighted editor! You see that the Syntax is not correct.
Escape the " in your code, you forgotten the ; after the echo:
<?php
if(isset($_SESSION['access_token'])) {
echo "Log out";
} else {
echo "Log In";
}
?>
It's normal . look at your echo . There are only double quotes. You have to use (for example) double quotes for echo, and single quotes to delimit logout.php and login.php
echo "<a href='logout.php'>Log out</a>";
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
The simplest question but I can't get it working... What's wrong with the way I'm trying to add an image to this php file?
<?php header("HTTP/1.0 404 Not Found"); ?>
<?php defined('C5_EXECUTE') or die("Access Denied."); ?>
<h1 class="error"><?php echo t('Page Not Found')?></h1>
<?php echo t('We could not find a page at this address.')?>
<?php if (is_object($c)) { ?>
<br/><br/>
<?php $a = new Area("Main"); $a->display($c); ?>
<?php } ?>
<?php
echo "<img src="img.jpg">"
?>
<?php echo t('Back to Home')?>.
The file named img.jpg sits in the same directory as this .php file. When it runs, I see this error: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in line 21 where line 21 is echo "<img src="img.jpg">".
instead of :
echo "<img src="img.jpg">";
you can do:
echo "<img src='img.jpg'>";
or
echo '<img src="img.jpg">';
or even escape the quote:
echo "<img src=\"img.jpg\">";
Two, or possibly three, things are wrong with the way you're adding an image.
You need to use different kinds of quotation marks (" vs '), otherwise they cancel each other out.
You need a ; to end the line in PHP
Your image path may be broken. If img.jpg is not in the same directory as the PHP script, it won't work.
Replace:
"<img src="img.jpg"/>"
with
"<img src='img.jpg'/>";
If the problem is with your image path, try using an absolute path (src="http://example.com/your/path/img.jpg") instead of the relative path (src="img.jpg"). If that works, then it means that the relative path was wrong.
You have a wrong quotation on the img line and then I suggest keeping it all in PHP. You can replace your code with this code which is more easy to read and maintain:
header("HTTP/1.0 404 Not Found");
defined('C5_EXECUTE') or die("Access Denied.");
echo '<h1 class="error">'. t('Page Not Found') .'</h1>';
echo t('We could not find a page at this address.');
if (is_object($c)) {
echo '<br /><br />';
$a = new Area("Main");
$a->display($c);
}
echo "<img src='img.jpg'>";
echo ''. t('Back to Home') .'.';