This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 5 years ago.
I am trying to echo multiple images but i get the error:
"PHP Parse error: syntax error, unexpected '?>' in
/public_html/View/Pages/Home.php on line 17".
Can you give me any guidance on how to fix it? code below
<?php
for($i=0;$i<$length;$i++) {
echo ?><img class="meme-image" src="<?php $meme["$imd_id" == "$i"]->$path?>"><?php
}
?>
Try By this.
<?php
for($i=0;$i<$length;$i++) {
echo '<img class="meme-image" src='.$meme[$imd_id == $i]->$path.' ">';
}
?>
Note : You do not require to close php tag. instead of that insert this in php echo.and also you must read this For best practice.
Related
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 2 years ago.
Hey below I tried to display my image, it may be from the way I referenced in the src. Any ideas hot to fix? Thanks
(I get Parse error: syntax error, unexpected '<' )
<td><?php echo <img src='"/images/thumbs/.$row['thumb']."';?></td>
more ways... just keep attention on " and ' orders
<td><?php echo '<img src="/images/thumbs/'.$row['thumb'].'"';?></td>
you may also use:
<td><?php echo "<img src=\"/images/thumbs/{$row['thumb']}\"";?></td>
hope to be usefull
A cleaner method:
<?php $foo = $row['thumb'];?>
<td><?php echo '<img src="/images/thumbs/'.$foo.'"';?></td>
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 4 years ago.
When I run this code, it always shows:
Parse error: syntax error, unexpected end of file in /opt/lampp/htdocs/japan_top10_09112018/index.php on line 30
<?php
echo "<title>Top 10 Things to Do in Japan</title>";
require_once('templates/header.php');
?>
<?php
// Ask teacher: does this code is right to show errors or necessary?
ini_set('display_errors', 1);
error_reporting(E_ALL | E_STRICT);
?>
<?php
require_once('database/data.php');
?>
<div class = "container">
<h1>Top 10 things to do in Japan</h1>
<?php
foreach($data as $info) {
print_r($info["Picture"]);
echo "<hr>";
// echo '<img src="$info["Picture"]" class="img-thumbnail">';
?>
<?php
require_once('templates/footer.php');
?>
The line 30 is the last line.
You are forgetting to add a } to close your foreach
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 5 years ago.
Here is the code below. I'm trying to put the default logo using PHP conditions in my wp theme. But it's showing an error. ( Parse error: syntax error, unexpected 'get_template_directory_uri' (T_STRING), expecting ',' or ';' in C:\wamp\www\law\wp-content\themes\digital-pro\header.php on line 64 )
if( has_custom_logo() ){
the_custom_logo();
}
else{
echo '<img src=" '.get_template_directory_uri().'/img/logo.png" alt="">';
}
Try it like this..
if( has_custom_logo() ){
the_custom_logo();
}
else{ ?>
<img src=" <?php echo get_template_directory_uri(); ?>/img/logo.png" alt="">
<?php }
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 5 years ago.
So I am getting the following parse error when this file loads:
Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE),
expecting identifier (T_STRING) or variable (T_VARIABLE) or number
(T_NUM_STRING)
I have tried everything to work out why and I narrowed it down to the
href=\"start.php?id=<?php echo $res['id'] ?>\"
section of the code. I am sure I left out a ' or " but unsure where as
it all makes sense to me. Can anyone with a keener eye see where I am
going wrong? Thank you.
My code:
<td>
<?php if($res['ndaSent'] == "No") {
echo "<span class=\"buttonTestDisabled\"> Start Test</span>";}
else {
echo "<a class=\"buttonTest\" href=\"start.php?id=<?php echo $res['id']
?>\">Start Test</a> ";}
?>
</td>
Take a look at that. You can't use echo command inside of an echo " " line. Try using ' inside and not \ may help you too from confusion.
<?php if($res['ndaSent'] == "No") {
echo "<span class='buttonTestDisabled'> Start Test</span>";
}else{
echo "<a class='buttonTest' href='start.php?id=".$res['id'].">Start Test</a>';}
?>
</td>
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 7 years ago.
I got
Parse error: syntax error, unexpected "", expected T_STRING
in ../services/sect_inc_prev.php on line 2
<div style="text-align: right;">
<? if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) die(); ?>
</div>
<div class="f13"></div>
what is expected as string and where to find the place where "" is?
I need to know where the problem "empty space". I'm not php programmer at all
I deleted the 2nd line and I have no error now, but I don't know for what it was needed. The error was on friend's page that hosted on Bitrix system
You should try this :
<? if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) die(); ?>
Just remove backslashes... Search a little bit more next time :)
Try without slashes:
<div style="text-align: right;">
<? if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) die(); ?>
</div>
<div class="f13"></div>