shwetapandit Posted November 18, 2013 Share Posted November 18, 2013 why unexpected end of file on line 49: <html><?phpsession_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> Quote Link to comment Share on other sites More sharing options...
KaiSheng Posted November 18, 2013 Share Posted November 18, 2013 is this a valid syntax? $display_block=<<<END_OF_BLOCK Quote Link to comment Share on other sites More sharing options...
Solution Ch0cu3r Posted November 18, 2013 Solution Share Posted November 18, 2013 (edited) 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 November 18, 2013 by Ch0cu3r Quote Link to comment Share on other sites More sharing options...
AaronClifford Posted November 18, 2013 Share Posted November 18, 2013 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> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.