How to Concatenate a PHP variable and a string [closed] - 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 6 years ago.
Improve this question
might be a very dumb question but i'm trying to make a html string with a php var and then html.. what the heck am I doing wrong?!? :(
$author_name = get_the_author(); ?>
<h4><?php $author_name;?> On-Demand Webinars</h4>
Thank you!

Just missed the echo.
<h4><?php echo $author_name;?> On-Demand Webinars</h4>

You missed "echo" statement
e.g
<?php echo $author_name;?> On-Demand Webinars
OR
<?=$author_name;?>

Related

Why I can't run a plugin anycomment on wordpress [closed]

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 1 year ago.
Improve this question
Now I try to install a plugin "anycomment" on my site. In single.php I inserted this:
<?php do_shortcode('[anycomment]') ?>
But it's not working. Why?
I attached screens with plugin:
First
Second screen
Can you help me with it? Thanks advance
Try
<?php echo do_shortcode('[anycomment]'); ?>

How to use esc_attr here? [closed]

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 2 years ago.
Improve this question
I don't know if it's ok how to use esc_attr in
echo $this->get_field_id( 'title' );
I got this. is it ok or is there an error?
echo esc_attr($this->get_field_id('title'););
If by esc_attr you mean the integrated wordpress function, you should put a string between the parenthesis. And it's used to escape html attributes.
In your case, you should get rid of the first semicolon:
echo esc_attr($this->get_field_id('title'));

Php help find where is syntax error [closed]

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
foreach($db->fetch_array("SELECT id_categories FROM csn_categories_join_kartes where id_kartes===".$card['id']."") as $kat){
echo (kat['id_categories']);
}
table cols and values are all matched, something is wrong in this part of code
I tried adding $ before kat and using only one "=", sill doesnt work
NEW LINK
http://pastebin.com/RPK7vEaJ
this
where id_kartes===".$card['id']."
would be
where id_kartes=".$card['id']."
and missing $
echo $kat['id_categories'];
so full code :-
foreach($db->fetch_array("SELECT id_categories FROM csn_categories_join_kartes where id_kartes='".$card['id']."'") as $kat){
echo $kat['id_categories'];
}
best practice if you store your query result in a variable and loop over this variable.
foreach($db->fetch_array("SELECT id_categories FROM csn_categories_join_kartes where id_kartes=".$card['id']."") as $kat)

$_GET function not working for my wordpress website [closed]

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
Here is the URL:
localhost/wordpress/?page_id=51.html?err=Please%20Enter%20your%20Password%20Confirmation
Here is the code that is not working:
<h2 class="site-description2">
<?php if(isset($_GET["err"])) echo $_GET["err"]; ?>
</h2>
Thanks in advance. Appreciate all help.
separate $_GET parameters with &
localhost/wordpress/?page_id=51.html&err=Please%20Enter%20your%20Password%20Confirmation

Using PHP inside a shortcode inside PHP... syntax issue [closed]

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
Ok, I'm OK with PHP but not an expert. What's the correct syntax here?
I'm trying to pull in an Advanced Custom Field data INSIDE some PHP, which is INSIDE a shortcode.
I have an ACF field called: the_sub_field("google_doc_key")
<div><?php echo do_shortcode("[gdoc key='https://docs.google.com/spreadsheets/d/"'. the_sub_field("google_doc_key") .'"/edit' gid='0']"); ?></div>
Somethings not right here... any help is appreciated.
<div><?php echo do_shortcode("[gdoc key='https://docs.google.com/spreadsheets/d/'". the_sub_field("google_doc_key") ."'/edit' gid='0']"); ?></div>
Try that, you had the ' and " mixed up just before the_sub_field

Categories