Jump to content

unexpected $end


adamriley

Recommended Posts

Hi to start with i know i have forgotten something but dont know what could some one tell me please

 

error log

------------------------------------------------------------------------

[sat Jan 23 18:54:03 2010] [error] [client 127.0.0.1] PHP Parse error:  syntax error, unexpected $end in C:\\web\\htdocs\\Files\\change\\adam1.php on line 40

 

--------------------------------------------------------------------------

Form.html

-----------------------------------------------------------

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Untitled Page</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div id="bv_Form1" style="position:absolute;left:33px;top:34px;width:341px;height:150px;z-index:2;" align="left">
<form name="Form1" method="POST" action="adam1.php" id="Form1">
<input type="text" id="Editbox1" style="position:absolute;left:25px;top:24px;width:150px;font-family:Courier New;font-size:16px;z-index:0" name="adam" value="">
<input type="submit" id="Button1" name="Button1" value="Submit" style="position:absolute;left:62px;top:69px;width:75px;height:24px;font-family:Arial;font-size:13px;z-index:1">

</form>
</div>
</body>
</html>

----------------------------------------------------------------------------------

adam1.php

---------------------------------------------------------------

<?php
$a1 = $_POST["adam"];
// Assign all HTML code within one single variable.
// All variables within HERDOC will be parsed
if ($a1 == 'on'){
/* CLOSE PHP HERE BECAUSE WE WANT TO OUTPUT HTML */ 
$stringData = <<<HTMLCODE
?>
<html>
<head>
<title>Your interact is on</title>
<body>
<h1>interact is now turned on</h1>
</body>
</html>
<?php HTMLCODE;
$myFile = "adam.html";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, "\n");
fwrite($fh, "$stringData\n");
fclose($fh);
}else{ /* OPEN PHP FOR THE ELSE THEN CLOSE IT FOR HTML AGAIN */ ?>
$stringData = <<<HTMLCODE
<html>
<head>
<title>Your interact is off</title>
<body>
<h1>interact is now turned off</h1>
</body>
</html>
<?php HTMLCODE;
$myFile = "adam.html";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, "\n");
fwrite($fh, "$stringData\n");
fclose($fh);
<?php }
} // OPEN PHP AGAIN FOR THE CLOSING BRACE
?>

Link to comment
https://forums.phpfreaks.com/topic/189551-unexpected-end/
Share on other sites

Multiple problems. As stated by Jay6390. Also, get rid of the extra stopping and starting of PHP, not needed. Your main problem, besides poor coding, was as with most unexpected end errors is the mismatching of brackets. You had an extra closing curly bracket at the end of the script.

 

<?php
$a1 = $_POST["adam"];
// Assign all HTML code within one single variable.
// All variables within HERDOC will be parsed
if ($a1 == 'on'){
/* CLOSE PHP HERE BECAUSE WE WANT TO OUTPUT HTML */
$stringData =
<<<HTMLCODE

<html>
<head>
<title>Your interact is on</title>
<body>
<h1>interact is now turned on</h1>
</body>
</html>
HTMLCODE;
$myFile = "adam.html";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, "\n");
fwrite($fh, "$stringData\n");
fclose($fh);
}else{ /* OPEN PHP FOR THE ELSE THEN CLOSE IT FOR HTML AGAIN */
$stringData =
<<<HTMLCODE
<html>
<head>
<title>Your interact is off</title>
<body>
<h1>interact is now turned off</h1>
</body>
</html>
HTMLCODE;
$myFile = "adam.html";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, "\n");
fwrite($fh, "$stringData\n");
fclose($fh);

} // OPEN PHP AGAIN FOR THE CLOSING BRACE
?>

 

 

HTH

Teamatomic

Link to comment
https://forums.phpfreaks.com/topic/189551-unexpected-end/#findComment-1000519
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.