twilitegxa Posted August 24, 2008 Share Posted August 24, 2008 I am working with a tutoril in a book on creating a mailing list, but I am getting an error on line 57: Parse error: syntax error, unexpected T_STRING in C:\wamp\www\files\manage.php on line 57 Here is the code: <?php //set up a couple of functions function doDB() { global $conn; //connect to server and select database; you may need it $conn = mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("smrpg",$conn) or die(mysql_error()); } function emailChecker($email) { global $conn, $check_result; //check that email is not already in list $check = "select id from subscribers where email = '$email'"; $check_result = mysql_query($check,$conn) or die(mysql_error()); } //determine if they need to see the form or not if ($_POST[op] != 'ds') { //they do, so create form block $display_block = " <form method=POST action=\"$_SERVER[php_SELF]\"> <p><strong>Your E-Mail Address:</strong><br /> <input type=text name=\"email\" size=40 maxlength=150> <p><strong>Action:</strong><br /> <input type=radio name=\"action\" value=\"sub\" checked> subscribe <input type=radio name=\"action\" value=\"unsub\"> unsubscribe <input type=\"hidden\" name=\"op\" value=\"ds\"> <p><input type=submit name=\"submit\" value=\"Submit Form\"></p> </form>"; } else if (($_POST[op] == "ds") && ($_POST[action] == "sub")) { //trying to subscribe; validate email address if ($_POST == "") { header("Location: manage.php"); exit; } //connect to database doDB(); //check that email is in list emailChecker($_POST); //get number of results and do action if (mysql_num_rows($check_result) < 1) { //add record $sql = "insert into subscribers values('', '$_POST')"; $result = mysql_query($sql,$conn) or die(mysql_error()); $display_block = "<p>Thanks for signing up!</p>"; } else { //print failure message $display_block = "<p>You're already subscribed!</p>; } } else if (($_POST[op] == "ds") && ($_POST[action] == "unsub")) { //trying to unsubscribe; validate email address if ($_POST == "") { header("Location: manage.php"); exit; } //connect to database doDB(); //check that email is in list emailChecker($_POST); //get number of results and do action if (mysql_num_rows($check_result) < 1) { //print failure message $display_block = "<p>Couldn't find your address!</p> <p>No action was taken.</p>"; } else { //unscubscribe $id = mysql_result($check_result, 0, "id"); $sql = "delete from subscribeers where id = '$id'"; $result = mysql_query($sql,$conn) or die(mysql_error()); $display_block = "<p>You're unsubscribed!</p>"; } } ?> <html> <head> <title>Subscribe/Unsubscribe</title> </head> <body> <h1>Subscribe/Unsubscribe</h1> <?php echo "$display_block"; ?> </body> </html> Can someone help me figure out what is wrong with that line? I can't figure it out! Any help would be greatly appreciated! Link to comment https://forums.phpfreaks.com/topic/121073-solved-mailing-list-problem/ Share on other sites More sharing options...
JasonLewis Posted August 24, 2008 Share Posted August 24, 2008 $display_block = "<p>You're already subscribed!</p>; I guess that's the line. Can you see the error? For Common Errors check this thread: http://www.phpfreaks.com/forums/index.php/topic,209860.0.html Link to comment https://forums.phpfreaks.com/topic/121073-solved-mailing-list-problem/#findComment-624150 Share on other sites More sharing options...
twilitegxa Posted August 24, 2008 Author Share Posted August 24, 2008 Thank you so much! That seems to have fixed it! I just couldn't find it for some reason. Thank you so much! Link to comment https://forums.phpfreaks.com/topic/121073-solved-mailing-list-problem/#findComment-624314 Share on other sites More sharing options...
DeanWhitehouse Posted August 24, 2008 Share Posted August 24, 2008 Please mark solved then. Link to comment https://forums.phpfreaks.com/topic/121073-solved-mailing-list-problem/#findComment-624536 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.