Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8608697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:41:00+00:00 2026-06-12T03:41:00+00:00

<div class=interactionLinksDiv> <a href=javascript:toggleReplyBox(‘.$fullname.’,’.$current_id.’,’.$current_id.’,’.$id.’,’.$thisRandNum.’)>REPLY</a> </div> I have call the javascript function toggleReplyBox with five

  • 0
<div class="interactionLinksDiv">
<a href="javascript:toggleReplyBox('.$fullname.','.$current_id.','.$current_id.','.$id.','.$thisRandNum.')">REPLY</a>
</div>

I have call the javascript function toggleReplyBox with five parameters. This code is written inside the php tags. But this code is not executing properly and the parameters are not being passed properly. If I call the function toggleReplyBox here with no parameters it works fine but thats not what I want.

<div class="interactionLinksDiv">
<a href="javascript:toggleReplyBox('<?php echo $fullname; ?>','<?php echo $current_id; ?>','<?php echo $current_id ; ?>','<?php echo $id; ?>','<?php echo $thisRandNum; ?>')">REPLY</a>
</div>

When I copied this code to the html part of my php file It works fine and the parameters are passed and the function executes properly.
But I want to know why the function is not able to work inside of the php tags when everything is the same.

function toggleReplyBox(sendername,senderid,recName,recID,replyWipit) {
$("#recipientShow").text(recName);
document.replyForm.pm_sender_name.value = sendername;
document.replyForm.pmWipit.value = replyWipit;
document.replyForm.pm_sender_id.value = senderid;
document.replyForm.pm_rec_name.value = recName;
document.replyForm.pm_rec_id.value = recID;
document.replyForm.replyBtn.value = "Send";
if ($('#replyBox').is(":hidden")) {
      $('#replyBox').fadeIn(1000);
} else {
      $('#replyBox').hide();
}      

}

Inside the php tags I changed the code :

print <<<HTML
<div class="interactionLinksDiv">
<a href="javascript:toggleReplyBox('$fullname','$current_id','$current_id','$id','$thisRandNum')">REPLY</a>
</div>
HTML;

And it is still showing the error
Parse error: syntax error, unexpected T_VARIABLE in C:\xampp\htdocs\Fluid Solution\fluid-solution-website-template\interact\profile1.php on line 130

Line 130 is the <a href... line.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T03:41:02+00:00Added an answer on June 12, 2026 at 3:41 am

    The first version of your code is neither PHP (javascript/HTML tags are “naked”) nor Javascript: the “.” string concatenation operator won’t work in Javascript, nor will the $variable expansion.

    You can get it to work in PHP like this:

    <?php
        $fullname = "Test";
        $current_id = 15;
        $id = 9;
        $thisRandNum = 42;
        // All lines beyond this point, and...
        print <<<HTML
    <div class="interactionLinksDiv">
    <a href="javascript:toggleReplyBox('$fullname','$current_id',
    '$current_id','$id','$thisRandNum')">REPLY</a>
    </div>
    HTML;
        // ...up to here, start at the first column (i.e. they are not indented).
    ?>
    

    Note that within the here-document (area between <<<HTML and HTML), you can’t use the string concatenation operator “.” (or any other).

    Or you can do as you did in the second version of your code, replacing only the variables with <?php echo $variablename; ?> and leaving all the rest as HTML.

    As a simpler example let’s consider an alert() box with message sent from PHP. This means that:

    1) the script is executed server side; anything between <?php ?> tags is executed, and its output replaces the tags themselves.

    After this phase, we no longer have PHP but a mix of HTML and Javascript, which can be executed by the client it’s sent to. So we want to have a HTML like

    <script type="text/javascript">
        alert('Hello, world');
    </script>
    

    To do this we can generate all the HTML in PHP:

    echo '<script type="text/javascript">';
    echo "alert('$message');";  // or also:  echo 'alert("' . $message . '");';
    echo '</script>';
    

    Or we can do it with a here-document, where operators do not work, but $variables do:

    echo <<<HEREDOCUMENT
    <script type="text/javascript">
        alert('$message');
    </script>
    HEREDOCUMENT;
    

    Or we can run it all in HTML, and only rely on PHP to generate the lone variable:

    <script type="text/javascript">
        alert('<?php echo $message; ?>');
    </script>
    

    But always you need to keep separated what it’s being done in PHP, what in Javascript, and what is in the HTML markup.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a div class named switch control which has a div class named
for example I have the following: I want to go through each div class
I have something like this currently: <div class = className style = position: absolute;
i have my html something like this... <div class = content> <div class =
I have some class like this <div class = student> <div class = name>Adam
I have some code: - count = 0 - @clients.each do |client| %div{:class =>
I have a div class that looks something like this: <div class=objects> X </div>
I have this code: <div class = content-dir-item> <p>Text input</p> <img src=./images/email.png class =
I have a div that changes class depending on where the user is on
Is it possible to have a div.class different based on a class that is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.