Question:

I keep getting an error in PHP, Why?

by  |  earlier

0 LIKES UnLike

Why isnt the following acceptable?

echo "<input type=text class=\"textBox\" name=" . $rows4['id'] . "_option1T" value=" . $rows5['option1'] . " readonly> <br>";

Where it says "name=..." thats where it is having the problem, why and how could i make it correct?

 Tags:

   Report

2 ANSWERS


  1. you need a \ before every &quot; that you want to print the the html.  where you the &quot; after name= is telling php to end the echo statment, then it has no idea what do do with all the text that comes afterward.

    the \ tells PHP that you want it to treat the following character like a piece of plain text, not a command

    try this

    echo &quot;&lt;input type=text class=\&quot;textBox\&quot; name=\&quot; . $rows4[&#039;id&#039;] . \&quot;_option1T\&quot; value=\&quot; . $rows5[&#039;option1&#039;] . \&quot; readonly&gt; &lt;br&gt;&quot;;


  2. Try:

    echo &#039;&lt;input type=&quot;text&quot; class=&quot;textBox&quot; name=&quot; &#039; . $rows4[&#039;id&#039;] . &#039;_option1T&quot; value=&quot; &#039; . $rows5[&#039;option1&#039;] . &#039; &quot; readonly /&gt;&lt; br /&gt;&#039;;

    Extra spaces to show single quotes and double quotes.

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.