I am facing a problem in my code. Whenever I try to insert
a text field then it’s giving an error. What’s wrong in the syntax here?
print '<table>';
print "<tr style='background-color:#CDC9C9;'>
<td><A HREF=\"http://localhost/cgi-bin/AddUser.cgi\">ADD</A></td>
<td></td>
<td><b>UserId</b></td>
<td><input type="text" name="UserId"></td>
<td><b>UserName</b></td>
<td><input type="text" name="User_Name"></td>
<td><input type="submit" name="Filter" value="Filter"> </td>
</tr>";
print"</table>";
If you have a double-quoted string then it can’t contain unescaped double-quotes (for, hopefully, obvious reasons).
Some ways to get around it:
1/ Escape the double quotes.
2/ Switch to a single-quoted string (as your string contains no variables or escape sequences).
Note: I had to change the single quotes in the style attribute to double quotes here.
3/ Use a here-doc.
4/ Choose a different quoting character.
But like so many of your problems, the real solution is to use a templating system.