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
Is there something wrong with the line beginning with echo? I'm getting this error but I'm not sure how I can change it: Parse error: syntax error, unexpected '.' on line 74
while ( have_rows('stills') ) : the_row();
// display a sub field value
echo '<li><img src="' . the_sub_field('still'); . '" alt="<?php the_sub_field('project_name'); ?>-still"></li>'
endwhile;
I changed it to this but it's still not outputting correctly: echo '<li><img src="' . the_sub_field('still') . '"></li>';
Also, if this isn't the area to ask for help on these types of questions, where can I ask?
Edit: Tried satyr607's solution and this is how it's outputted.
<div class="project-stills">
<h3>Stills</h3>
http://localhost/wordpress/wp-content/uploads/2014/12/17.jpg
<li><img src="" alt="-still"></li>
</div>
Try this:
echo '<li><img src="' . the_sub_field('still') . '" alt="' . the_sub_field('project_name') . '-still"></li>';
watch your escaping.
Related
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 6 years ago.
Improve this question
Can anyone help me for this why doesn't my code work?
$h.= ' 'mysql_result($res,$z,"name")'';
It gives me an error because of the <a href
$h .= ''.mysql_result($res,$z,"name").'';
Should work now
. before mysql_result and after.
Also take a look here it will help you to understand String Operators and etc.
You need to concatenate.
$h.= ' ' . mysql_result($res,$z,"name") . '';
Anyway, I would suggest you to put mysql_result($res,$z,"name") into a variable, to increase readability and avoid executing the function every time you call it.
I mean:
$name = mysql_result($res,$z,"name");
$h.= ' ' . $name . '';
Try this
$h.= ''.mysql_result($res,$z,"name").'';
You are missing . the concatenation operator
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 am unable to view images on my webserver in php and I keep getting server 500 error.
I believe that it is this line of code echo "<img src='$row["sourchPath"]'>":
while ($row = mysqli_fetch_assoc($result)){
if($row){
echo $row["sourchPath"]; // this works
echo "<img src='$row["sourchPath"]'>";
}
else {
echo "error";
}
}
My file directory is like images/football.jpg
The problem is because of this line:
echo "<img src='$row["sourchPath"]'>"; // syntax error
It should be,
echo "<img src='" . $row["sourchPath"] . "' />";
You may use
echo "<img src='" . $row["sourchPath"] . "'>";
in place of your code.
It will work
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 am trying to display an image using a variable "$images" that contains the URL parsed form an API.
This is my code:
echo "<td>""<img src='",$image,"'>""</td>\n";
I assume there is a typo I cannot detect because I get a blank screen when running this.
echo "<td>"."<img src='".$image."'>"."</td>";
Or
echo "<td><img src='".$image."'></td>";
You were missing the dots/commas after/before the td tags
use . not ,
<img src='".$image."'>
PHP requires that you chain your strings together using a .
E.g.
echo 'Test' . ' ' . 'Hello'; // Test Hello
Or simply :
echo "<td><img src='$image'></td>";
Check documentation.
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
PHP Parse error: syntax error, unexpected T_OBJECT_OPERATOR in ...
tpl->set( '[complaint]', "<a href=\"javascript:AddComplaint('" . $row['id'] . "', 'comments')\">" );
What in this code causing problem, please help to find answer.
You're missing the dollar sign before your variable name:
tpl->set( '[complaint]', "<a href=\"javascript:AddComplaint('" . $row['id'] . "', 'comments')\">" );
should be:
$tpl->set( '[complaint]', "<a href=\"javascript:AddComplaint('" . $row['id'] . "', 'comments')\">" );
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 9 years ago.
Improve this question
how can I print out a variable name in text in php?
I want to accomplish something as simple as having this:
echo "|" . "$myvariable" . "|";
print out this:
|$myvariable|
instead of this:
||
how can I accomplish this?
Use single quotes so that the variables don't get interpolated:
echo "|" . '$myvariable' . "|";
As others pointed out, use single quotes to show the variable name "as is".
echo "|" . '$myvariable' . "|";
Be sure to read this part of the manual.