Image wont display from mysql [duplicate] - php

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>

Related

PHP: Edit href in <a> link [duplicate]

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 3 years ago.
I want to edit the URL to a specific URL as I can't find the user meta in WordPress nor in the phpMyAdmin in the cPanel.
I want to change this:
if(get_user_meta( $user_id, 'googleplus', $single) !=""){
echo "<br/><a class='author-link g' title='Follow on Google+' href=".get_user_meta( $user_id, googleplus', $single )." target='_blank'>Google+</a>";
}
To:
if(get_user_meta( $user_id, 'googleplus', $single) !=""){
echo "<br/><a class='author-link g' title='Follow on Google+' href="https://example.com" target='_blank'>Google+</a>";
}
And the error is:
syntax error, unexpected 'https' (T_STRING), expecting ',' or ';'
I have tried:
href="<?php echo "http://www.example.com"; ?>"
href="https:\/\/www.example.com"
href="https://www.example.com"
Would appreciate any advice as I have zero knowledge in PHP.
You have an error in using single quoted and double quoted
in your code
change "example.com" to 'example.com'
OR use it like this way \"example.com\" to escape double quoted
The finnal right code will be
if(get_user_meta( $user_id, 'googleplus', $single) !=""){
echo "<br/><a class='author-link g' title='Follow on Google+' href='https://example.com' target='_blank'>Google+</a>";
}
change
echo "<br/><a class='author-link g' title='Follow on Google+' href="https://example.com" target='_blank'>Google+</a>";
to
echo '<br/><a class="author-link g" title="Follow on Google+" href="https://example.com" target="_blank">Google+</a>';

Syntax error - PHP if statement in html td tag [duplicate]

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 3 years ago.
I get this message in my browser: Parse error: syntax error, unexpected 'if' (T_IF)
I have been making a HTML table showing prices on a Woocommerce product.
I have seen a lot of similar issues, but cannot relate to my own problem.
The problem should be in this code...
<tr>
<td>'. $product_variation->get_name() .'</td>
<td>'. $product_variation->get_regular_price() .'</td>
<td>'
if($sale_price) {
echo $sale_price;
}else {
echo $product_variation->get_regular_price();
}
'</td>
</tr>';ยดยดยด
use php Tags around this:-
<?php
if($sale_price) {
echo $sale_price;
}else {
echo $product_variation->get_regular_price();
}
?>

I can't get to echo images with php [duplicate]

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.

I'm trying to put the a defualt logo in WP theme using if, else condition. But doesn't working [duplicate]

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 }

php can't find syntax error in echo line [duplicate]

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>

Categories