Jump to content

unexpected end of file on line 49


Go to solution Solved by Ch0cu3r,

Recommended Posts

why unexpected end of file on line 49:

 

 

<html>
<?php
session_start();
if(isset($_POST['submit'])){
if (isset($_SESSION['email'])) {
$uid=$_SESSION['uid'];

$con=mysql_connect("localhost","root","")or die(mysql_error());
mysql_select_db("regis")or die(mysql_error());

$add1=$_POST['add1'];
$add2=$_POST['add2'];
$city=$_POST['city'];
$state=$_POST['state'];
$country=$_POST['country'];
if (isset($_POST['set'])){
$sett=$_POST['set'];
}

//check if the default address is already set.
$check = mysql_query("SELECT uid FROM address WHERE uid = '$uid' and sett='1' ")
or die(mysql_error());
 $check2 = mysql_num_rows($check);
 //if the default already set, it gives an error
 if ($check2 != 0) {
         die('Sorry, the default is already set.would you like to change it');
$display_block=<<<END_OF_BLOCK
<form action="update.php" method="POST">
<h2>Would you like to change your default address</h2>
yes:<input type="radio" name="update" value="1"><br/>
No:<input type="radio" name="update" value="0"><br/>
<input type="submit" value="submit" name="submit">
</form>
END_OF_BLOCK;                 
}
else if($check2 == 0){
mysql_query("INSERT INTO address (uid, add1, add2, city, state, country ,sett )
VALUES ('$uid', '$add1','$add2' ,'$city' ,'$state' ,'$country' , '$sett' )")
or die(mysql_error());
echo "Your address get saved in our Database";
echo "<br/>";
}
 }
 }
?>
<a href="logout.php">logout</a><br/>
<a href="add_address.php">Would you like to add another address</a><br/>
<a href="default.html">Next Page</a>
</html>

Link to comment
https://forums.phpfreaks.com/topic/284013-unexpected-end-of-file-on-line-49/
Share on other sites

  • Solution

is this a valid syntax?

$display_block=<<<END_OF_BLOCK

Yes it is heredoc syntax

 

@shwetapandit

 

You have spaces after END_OF_BLOCK; make sure there is only a new line directly after the ;

 

 

END_OF_BLOCK;                 <--- Remove these spaces

             ^^^^^^^^^^^^^^^^^

Edited by Ch0cu3r

Yep as Ch0cur3r has said the below will work (removed the whitespace after END_OF_BLOCK.

<html>
<?php
session_start();
if(isset($_POST['submit'])){
if (isset($_SESSION['email'])) {
$uid=$_SESSION['uid'];

$con=mysql_connect("localhost","root","")or die(mysql_error());
mysql_select_db("regis")or die(mysql_error());

$add1=$_POST['add1'];
$add2=$_POST['add2'];
$city=$_POST['city'];
$state=$_POST['state'];
$country=$_POST['country'];
if (isset($_POST['set'])){
$sett=$_POST['set'];
}

//check if the default address is already set.
$check = mysql_query("SELECT uid FROM address WHERE uid = '$uid' and sett='1' ")
or die(mysql_error());
 $check2 = mysql_num_rows($check);
 //if the default already set, it gives an error
 if ($check2 != 0) {
         die('Sorry, the default is already set.would you like to change it');
$display_block=<<<END_OF_BLOCK
<form action="update.php" method="POST">
<h2>Would you like to change your default address</h2>
yes:<input type="radio" name="update" value="1"><br/>
No:<input type="radio" name="update" value="0"><br/>
<input type="submit" value="submit" name="submit">
</form>
END_OF_BLOCK;
}
else if($check2 == 0){
mysql_query("INSERT INTO address (uid, add1, add2, city, state, country ,sett )
VALUES ('$uid', '$add1','$add2' ,'$city' ,'$state' ,'$country' , '$sett' )")
or die(mysql_error());
echo "Your address get saved in our Database";
echo "<br/>";
}
 }
 }
?>
<a href="logout.php">logout</a><br/>
<a href="add_address.php">Would you like to add another address</a><br/>
<a href="default.html">Next Page</a>
</html>
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.