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 8647293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:01:57+00:00 2026-06-12T13:01:57+00:00

I have this line of code below: foreach ($searchResults as $key=>$question) { echo ‘<tr

  • 0

I have this line of code below:

     foreach ($searchResults as $key=>$question) {

 echo '<tr class="questiontd"><td>'.htmlspecialchars($question).'</td>';
 echo '<td class="optiontypetd">'.htmlspecialchars($searchOption[$key]).'</td>';
 echo '<td class="noofanswerstd">'.htmlspecialchars($searchNoofAnswers[$key]).'</td>';
 echo '<td class="answertd">'.htmlspecialchars($searchAnswer[$key]).'</td>';
 echo '<td class="noofrepliestd">'.htmlspecialchars($searchReply[$key]).'</td>';
 echo '<td class="noofmarkstd">'.htmlspecialchars($searchMarks[$key]).'</td>';
 echo "<td class='addtd'><button type='button' class='add' onclick=\"parent.addwindow('$question','$searchMarks[$key]','$searchNoofAnswers[$key]','$searchOption[$key]','$searchReply[$key]','$searchAnswer[$key]');\">Add</button></td></tr>";
}

Now I wanted to use str_repace to replace some string characters but when I do this I get this error in the line above:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in
…text.php on line 154

How can I remove this error?

UPDATE:

OK I remove the single quote as mentioned but problem is that it messes my add button up. I am now getting this error when I click on the “Add” button:

syntaxError: unterminated string literal error:

parent.addwindow(‘!

The line of code where the error is displayed like this in the console:

<button type='button' class='add' onclick="parent.addwindow('!"�$%^&*()-=\'.,:;/?#~*/\\><'

How can this be fixed?

  • 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-12T13:02:01+00:00Added an answer on June 12, 2026 at 1:02 pm

    T_CONSTANT_ENCAPSED_STRING is basically a quote mismatch. StackOverflow’s syntax highlighter makes it more obvious with the color change.

    $question')
    

    Remove the single quote and you should be good.

    Follow-up:

    • PHP Parser Tokens
    • PHP String Syntax

    Alternatives:

    As Cups mentioned, you can use heredoc (though I personally think it doesn’t help in this particular scenario from a readability standpoint–you’re still embedding a lot of variables within HTML syntax). Another method is to store the parent.addwindow arguments as a variable then pass it within the string (save yourself from both an extended echo line and worrying about quote mis-matches. For example:

    $addWindowArgs = "'" . implode("','", array(
      str_replace('"','&quot;', $question),
      $searchMarks[$key],
      $searchNoofAnswers[$key],
      $searchOption[$key],
      $searchReply[$key],
      $searchAnswer[$key]
    )) . "'";
    
    echo  "<td class=\"addtd\">"
        . "<button type=\"button\" class=\"add\" onclick=\"parent.addwindow({$addWindowArgs});\">Add</button>"
        . "</td></tr>";
    

    Alternatively, you can use sprintf instead of implode with the same echo call:

    $addWindowArgs = sprintf("'%s','%s','%s','%s','%s','%s'",
      str_replace('"','&quot;', $question),
      $searchMarks[$key],
      $searchNoofAnswers[$key],
      $searchOption[$key],
      $searchReply[$key],
      $searchAnswer[$key]
    );
    

    This gives you more control in case some arguments are numbers, some are strings, etc.

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

Sidebar

Related Questions

Say I have this line of code in the view. <?php echo CHtml::activeTextField($model,'start_time'); ?>
I have this line of code but it throws an error. What is the
I have this line of code: this.Path = pathLookUpLocation.GetValue(RegLookupKey, null).ToString(); When I run static
I have this line of code: System.Drawing.Icon icon = System.Drawing.Icon.FromHandle(shinfo.hIcon); A few lines later,
Sorry, I'm new to flash I have this line of code: BaseEntry( _entryList[i] ).topTeamName
I have this line in my code: myGridView.setChoiceMode(GridView.CHOICE_MODE_MULTIPLE); It works perfectly fine in ICS,
I have this code in my controller and want to test this code line
I have found this line of code in a game that I study int
I have found this line of MatLab code on the internet that displays a
For example we have this line chart at Google Code API there is a

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.