Jump to content

syntax error, unexpected '}' in C:\wamp\www\emailsubunsub\manage.php on line 59


shwetapandit
Go to solution Solved by PravinS,

Recommended Posts

hi.....

I m new in php.i have syntax error, unexpected '}' in C:\wamp\www\emailsubunsub\manage.php on line 59 error in my snippet.if anyone fi bug or suggest me same then it would be great help for me.

<?php
include 'subscribe_include.php';
//determine if they need to see the form or not
if(!$_POST){
//they need to see the form,so create the form block
$display_block=<<<END_OF_BLOCK
<form method='POST' action-"$_SERVER[PHP_SELF]">

Your E-mail address :
<input type="email" id="email" name="email"
size="40" maxlength="150"/>

<fieldset>
<legend>Action :</legend><br/>
Subscribe :
<input type="radio" id="action_sub" name="action"
 value="sub" checked/><br/>
Unsubscribe :
<input type="radio" id="action_unsub" name="action"
 value="unsub"/>
</fieldset>

<button type="submit" name="submit"
value="submit">Submit</button>
</form>
END_OF_BLOCK;
}
else if(($_POST)&&($_POST['action']=="sub")){
//trying to subscribe;validate e-mail address
if(($_POST['email']==" ")){
header("Location:manage.php");
exit;}
else{
//connect to database
doDB();

//check that mail is in list
emailChecker($_POST['email']);

//get number of results and do action
if(mysqli_num_rows($check_res)<1){

//free result
mysqli_free_result($check_res);

//add record
$add_sql="INSERT INTO Subscribers_DB(email)
VALUES ('".$safe_email."')";
$add_res=mysqli_query($mysqli,$add_sql)
or die(mysqli_error($mysqli));
$display_block="<p>Thanks for signing up</p>";
      
//close connection to mysql
mysqli_close($mysqli);
}
else{
//print failure message
$display_block="<p>You are already subscribed!</p>"
   }  
 }
}
else if(($_POST)&&($_POST['action']=="unsub")){
//trying to unsubscribe;validate e-mail address
if($_POST['email']==""){
header("Location:manage.php");
exit;
}
else{
//connect to database
doDB();

//check that email is in list
emailChecker($_POST['email']);

//get number of results and do action
if(mysqli_num_rows($check_res)<1){
//free result
mysqli_free_result($check_res);

//print failure message
$display_block="<p>Couldn,t find your address!</p><p>No action was taken</p>";
}
else{
//get value of id from result
while($row=mysqli_fetch_array($check_res)){
$id=$row['id'];
}

//unsubscribe the address
$del_sql="DELETE FROM Subscribers_db WHERE id=".$id;
$del_res=mysqli_query($mysqli,$del_sql)or die(mysqli_error($mysqli));
$display_block="<p>You're unsubscribed!</p>";
}
mysqli_close($mysqli);
}
}
?>
<html>
<head>
<title>Subscribe/Unsubscribe to a mailing list</title>
</head>
<body>
<h1>Subscribe/Unsubscribe to a mailing list</h1>
<?php
echo "$display_block";?>
</body>
</html>
Edited by Maq
Link to comment
Share on other sites

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.