frijole Posted January 30, 2008 Share Posted January 30, 2008 I am having trouble, im simply trying to make a list of emails people input for a mailing list, major newbie. <?php /*Program: email.php *Desc: PHP program that sends an email address to the DB for a mailing list. */ if(ini_get("magic_quotes_gpc") == "1") { $_POST['email'] = stripslashes($_POST['email']); } $host="localhost"; $user="removed"; $password="removed"; if(!empty($_POST['form'])) { mysql_connect($host,$user,$password); mysql_select_db(thinksna_email); $result = mysql_query($_POST['email']); if($result == false) { echo "<h4>Error: ".mysql_error($cxn)."</h4>"; } else { $email = $_POST['email']; INSERT INTO email (email, email_id, dateTime) VALUES ('$email', "" , NOW()); echo "'$email' was added to the list"; } ?> and here is the html form if that helps. DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xml:lang="en"> <meta http-equiv="Content-Type" content="text/html"; charset="UTF-8" /> <head> <title>thinksnack.com</title> <link rel="stylesheet" type="text/css" href="web.css"> <link rel="Shortcut Icon" type="image" href="favicon.ico"> </head> <body> <form action="email.php" method="POST"> <input type="text" email="email"> <input type="submit" value="add my e-mail"> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/88520-solved-parse-error-syntax-error-unexpected-t_string-in-homethinksnapublic_htmlema/ Share on other sites More sharing options...
andrew6607 Posted January 30, 2008 Share Posted January 30, 2008 What Line Dose It Say It Has the Error? Quote Link to comment https://forums.phpfreaks.com/topic/88520-solved-parse-error-syntax-error-unexpected-t_string-in-homethinksnapublic_htmlema/#findComment-453168 Share on other sites More sharing options...
Philip Posted January 30, 2008 Share Posted January 30, 2008 You have: INSERT INTO email (email, email_id, dateTime) VALUES ('$email', "" , NOW()); out in the middle of nowhere. You need to do something with it (i.e. echo it, put it in a query) Quote Link to comment https://forums.phpfreaks.com/topic/88520-solved-parse-error-syntax-error-unexpected-t_string-in-homethinksnapublic_htmlema/#findComment-453204 Share on other sites More sharing options...
laffin Posted January 30, 2008 Share Posted January 30, 2008 datetime is a mysql reserved word, either encase it in `back quotes` or change the db fieldname Quote Link to comment https://forums.phpfreaks.com/topic/88520-solved-parse-error-syntax-error-unexpected-t_string-in-homethinksnapublic_htmlema/#findComment-453213 Share on other sites More sharing options...
frijole Posted January 30, 2008 Author Share Posted January 30, 2008 [move]I need some help PLEASE![/move] Quote Link to comment https://forums.phpfreaks.com/topic/88520-solved-parse-error-syntax-error-unexpected-t_string-in-homethinksnapublic_htmlema/#findComment-453938 Share on other sites More sharing options...
frijole Posted January 30, 2008 Author Share Posted January 30, 2008 how can i format the DB query in the PHP? is that mysqli? Quote Link to comment https://forums.phpfreaks.com/topic/88520-solved-parse-error-syntax-error-unexpected-t_string-in-homethinksnapublic_htmlema/#findComment-453939 Share on other sites More sharing options...
Philip Posted January 31, 2008 Share Posted January 31, 2008 mysql_query("INSERT INTO email (email, email_id, dateTime) VALUES ('$email', "" , NOW())") or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/88520-solved-parse-error-syntax-error-unexpected-t_string-in-homethinksnapublic_htmlema/#findComment-454041 Share on other sites More sharing options...
frijole Posted January 31, 2008 Author Share Posted January 31, 2008 Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING Line 29 this error popped up now that the previous one was dealt with, any ideas? <?php /*Program: email.php *Desc: PHP program that sends an email address to the DB for a mailing list. */ if(ini_get("magic_quotes_gpc") == "1") { $_POST['email'] = stripslashes($_POST['email']); } $host="localhost"; $user="removed"; $password="removed"; if(!empty($_POST['form'])) { mysql_connect($host,$user,$password); mysql_select_db(thinksna_email); $result = mysql_query($_POST['email']); if($result == false) { echo "<h4>Error: ".mysql_error($cxn)."</h4>"; } else { $email = $_POST['email']; mysql_query("INSERT INTO email (email, email_id, dateTime) VALUES ('$email', "" , NOW())"); echo "'$email' was added to the list"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/88520-solved-parse-error-syntax-error-unexpected-t_string-in-homethinksnapublic_htmlema/#findComment-454067 Share on other sites More sharing options...
frijole Posted January 31, 2008 Author Share Posted January 31, 2008 ill start a new thread. Quote Link to comment https://forums.phpfreaks.com/topic/88520-solved-parse-error-syntax-error-unexpected-t_string-in-homethinksnapublic_htmlema/#findComment-454085 Share on other sites More sharing options...
kenrbnsn Posted January 31, 2008 Share Posted January 31, 2008 Answered in your new thread. Please don't double post. Ken Quote Link to comment https://forums.phpfreaks.com/topic/88520-solved-parse-error-syntax-error-unexpected-t_string-in-homethinksnapublic_htmlema/#findComment-454089 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.