2

Without this code my web page work fine...

echo "<form name="Patient" action="patient_history_display.php" method="get">";
    echo "<input type="submit" value="Click here to view patient history">";
echo "</form>";

However, after adding this part of code, I received two errors:

ERROR 1: SCREAM: Error suppression ignored for ERROR 2: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'

1
  • Because of incorrect quotes. Take a look at the syntax highlighting of your code here, it should help. Commented Apr 26, 2014 at 2:44

2 Answers 2

3

You're not escaping quotes " although for echo you should start and close with single quote '

echo '<form name="Patient" action="patient_history_display.php" method="get">';
echo '<input type="submit" value="Click here to view patient history">';
echo '</form>';

and by escaping, I mean adding a backslash to the " inside the echo like so:

echo "<form name=\"Patient\" action=\"patient_history_display.php\" method=\"get\">";
echo "<input type=\"submit\" value=\"Click here to view patient history\">";
echo "</form>";

as you can see, it's a hell of a lot easier to use quotes wisely!

or for big block stuff:

    echo <<<END
This uses the "here document" syntax to output
multiple lines with $variable interpolation. Note
that the here document terminator must appear on a
line with just a semicolon. no extra whitespace!
END;

https://www.php.net/echo

Sign up to request clarification or add additional context in comments.

4 Comments

Just to add, you could alternatively use one echo statement instead of three :)
You can, including echo <<<End'ing. Updated :)
Well there's a couple of ways to go about it. You could either use Heredoc, break context or echo using embedded newlines. For large blocks of static HTML, I'd typically just break context.
I find I break context less and less these days, don't know why but hey ho
1

Change the quotes from "" to ''. Try: echo '<input type="submit" value="Submit">';

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.