problem with Heredoc
Posted: Tue Jan 20, 2004 2:44 am
Hi,
Have been trying to solve this for a while. What's wrong with my Heredoc code ?
Error message :
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in c:\program files\easyphp1-7\www\microsent\pages\pass_answer.php on line 116
line 116 = if (isset($_POST["changecheck"])) {
$changecheck = $_POST["changecheck"];
}
<?php
// create short variable names
$id = "";
$login=$_POST['login'];
$passe=$_POST['passe'];
$npasse=$_POST['npasse'];
$npasse2=$_POST['npasse2'];
$html=<<<ETO
<tr height="45">
<td width="150" height="45"></td>
<td width="214" height="45" valign="top" align="left" xpos="735"><img src="../media/logowebmediasoft.jpg" width="200" height="45" border="0"></td>
<td width="1" height="45"><spacer type="block" width="1" height="45"></td>
</tr>
<tr height="1" cntrlrow>
<td width="585" height="1"><spacer type="block" width="585" height="1"></td>
<td width="150" height="1"><spacer type="block" width="150" height="1"></td>
<td width="214" height="1"><spacer type="block" width="214" height="1"></td>
<td width="1" height="1"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td width="2" bgcolor="#c6b017"></td>
</tr>
<tr height="2">
<td width="2" height="2" bgcolor="#c6b017"></td>
<td height="2" bgcolor="#c6b017"></td>
<td width="2" height="2" bgcolor="#c6b017"></td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<p></p>
</body>
</html>
ETO;
if (isset($_POST["changecheck"])) {
$changecheck = $_POST["changecheck"];
}
else
{ $changecheck = "0"; }
if ($changecheck != "1")
{
if (!$login || !$passe)
{
echo 'You must enter your login and password.<br />'
.'Please go back and try again.';
echo $html;
exit;
} }
else
{
if (!$login || !$passe || !$npasse || !$npasse2)
{
echo 'You must enter all the fields.<br />'
.'Please go back and try again.';
echo $html;
exit;
}
if ($npasse !== $npasse2)
{
echo 'You have made a mistake while entering the passwords.<br />'
.'Please go back and try again.';
echo $html;
exit;
}
}
$id = addslashes($id);
$login = addslashes($login);
$passe = addslashes($passe);
$npasse = addslashes($npasse);
@ $db = mysql_pconnect('localhost', 'root', '');
if (!$db)
{
echo 'Error: Could not connect to database. Please try again later.';
echo $html;
exit;
}
mysql_select_db('mailelani') or exit("Could not connect");
// checkin if the login exists
$sql_login_check = "SELECT * FROM passe WHERE login='$login'";
$result_login_check = mysql_query($sql_login_check);
$loginfound = mysql_num_rows($result_login_check);
// if login not found, note that and end
if ($loginfound < 1) {
echo "Login '" .$login ."' not found in the database !";
echo $html;
exit;
// if login does exist, continue with processing
}
else {
{
// checking if old password matches with the one in database
$sql_passe_check = "SELECT * FROM passe WHERE login='$login' and passe='$passe'";
$result_passe_check = mysql_query($sql_passe_check);
$passefound = mysql_num_rows($result_passe_check); }
//if checkbox not checked (=password)
if ($changecheck != "1")
{
if ($passefound < 1) {
echo "Password '" .$passe ."' didn't match with the password recorded in the database ! Please go back and try again.";
echo $html;
exit;
}
else {
echo " OK password correct !!!!";
echo $html;
exit;
}
}
else {
if ($passefound < 1) {
echo "Password '" .$passe ."' didn't match with the password recorded in the database ! Please go back and try again.";
echo $html;
exit;
}
else {
$query = "UPDATE passe SET passe = '{$npasse}' WHERE login = '{$login}' LIMIT 1" ;
$result = mysql_query($query);
echo $result ." password modified";
}}}
?>
Have been trying to solve this for a while. What's wrong with my Heredoc code ?
Error message :
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in c:\program files\easyphp1-7\www\microsent\pages\pass_answer.php on line 116
line 116 = if (isset($_POST["changecheck"])) {
$changecheck = $_POST["changecheck"];
}
<?php
// create short variable names
$id = "";
$login=$_POST['login'];
$passe=$_POST['passe'];
$npasse=$_POST['npasse'];
$npasse2=$_POST['npasse2'];
$html=<<<ETO
<tr height="45">
<td width="150" height="45"></td>
<td width="214" height="45" valign="top" align="left" xpos="735"><img src="../media/logowebmediasoft.jpg" width="200" height="45" border="0"></td>
<td width="1" height="45"><spacer type="block" width="1" height="45"></td>
</tr>
<tr height="1" cntrlrow>
<td width="585" height="1"><spacer type="block" width="585" height="1"></td>
<td width="150" height="1"><spacer type="block" width="150" height="1"></td>
<td width="214" height="1"><spacer type="block" width="214" height="1"></td>
<td width="1" height="1"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td width="2" bgcolor="#c6b017"></td>
</tr>
<tr height="2">
<td width="2" height="2" bgcolor="#c6b017"></td>
<td height="2" bgcolor="#c6b017"></td>
<td width="2" height="2" bgcolor="#c6b017"></td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<p></p>
</body>
</html>
ETO;
if (isset($_POST["changecheck"])) {
$changecheck = $_POST["changecheck"];
}
else
{ $changecheck = "0"; }
if ($changecheck != "1")
{
if (!$login || !$passe)
{
echo 'You must enter your login and password.<br />'
.'Please go back and try again.';
echo $html;
exit;
} }
else
{
if (!$login || !$passe || !$npasse || !$npasse2)
{
echo 'You must enter all the fields.<br />'
.'Please go back and try again.';
echo $html;
exit;
}
if ($npasse !== $npasse2)
{
echo 'You have made a mistake while entering the passwords.<br />'
.'Please go back and try again.';
echo $html;
exit;
}
}
$id = addslashes($id);
$login = addslashes($login);
$passe = addslashes($passe);
$npasse = addslashes($npasse);
@ $db = mysql_pconnect('localhost', 'root', '');
if (!$db)
{
echo 'Error: Could not connect to database. Please try again later.';
echo $html;
exit;
}
mysql_select_db('mailelani') or exit("Could not connect");
// checkin if the login exists
$sql_login_check = "SELECT * FROM passe WHERE login='$login'";
$result_login_check = mysql_query($sql_login_check);
$loginfound = mysql_num_rows($result_login_check);
// if login not found, note that and end
if ($loginfound < 1) {
echo "Login '" .$login ."' not found in the database !";
echo $html;
exit;
// if login does exist, continue with processing
}
else {
{
// checking if old password matches with the one in database
$sql_passe_check = "SELECT * FROM passe WHERE login='$login' and passe='$passe'";
$result_passe_check = mysql_query($sql_passe_check);
$passefound = mysql_num_rows($result_passe_check); }
//if checkbox not checked (=password)
if ($changecheck != "1")
{
if ($passefound < 1) {
echo "Password '" .$passe ."' didn't match with the password recorded in the database ! Please go back and try again.";
echo $html;
exit;
}
else {
echo " OK password correct !!!!";
echo $html;
exit;
}
}
else {
if ($passefound < 1) {
echo "Password '" .$passe ."' didn't match with the password recorded in the database ! Please go back and try again.";
echo $html;
exit;
}
else {
$query = "UPDATE passe SET passe = '{$npasse}' WHERE login = '{$login}' LIMIT 1" ;
$result = mysql_query($query);
echo $result ." password modified";
}}}
?>