poleman Posted February 9, 2007 Share Posted February 9, 2007 Hi, I can get data from a form into a databse ok, all fields are fine except the Email field. I get the message "Array " in the back end SQL database. Any idea how i can change something to make sure this is being entered and shown correctly? Thanks Rich Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 9, 2007 Share Posted February 9, 2007 We'd need to see the code. The HTML form (just the form please!) and the processing PHP code. Make sure to highlight your code and hit the # button to put it in code tags. Quote Link to comment Share on other sites More sharing options...
poleman Posted February 9, 2007 Author Share Posted February 9, 2007 here you go.... thanks :-) <form method="POST" action="newsletterfinal.php"> Name: <input type="text" name="name" size="20"><br> Surname: <input type="text" name="surname" size="20"><br> City: <input type="text" name="city" size="20"><br> Email <input type="text" name="email" size="30"> <br> <br> <button name="B1">Subscribe</button><br> <br> <br> </p> </form> <?php $con = mysql_connect ("db778.oneandone.co.uk","dbo191523061","zcMcsqnB"); if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("db191523061", $con);$sql="INSERT INTO Newsletter(name, surname, city, email) VALUES ('$_POST[name]','$_POST[surname]','$_POST[city]','$_POST ')";if (!mysql_query ($sql,$con)) { die('Error: ' . mysql_error()); } echo "Thank you for subscribing to the JSay Newsletter. We look forward to keeping you up to date with what's happening on JSay and in your community.";mysql_close($con) ?> Quote Link to comment Share on other sites More sharing options...
artacus Posted February 9, 2007 Share Posted February 9, 2007 Holy nbsp batman! Make sure to highlight your code and hit the # button to put it in code tags. So much for following directions. Take out the line break between $_POST and Quote Link to comment Share on other sites More sharing options...
poleman Posted February 9, 2007 Author Share Posted February 9, 2007 Thanks... I did that but still get the Array error in the database back end... here is the new code... <?php $con = mysql_connect ("db778.oneandone.co.uk","dbo191523061","zcMcsqnB"); if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("db191523061", $con);$sql="INSERT INTO Newsletter(name, surname, city, email) VALUES ('$_POST[name]','$_POST[surname]','$_POST[city]','$_POST [email]')";if (!mysql_query ($sql,$con)) { die('Error: ' . mysql_error()); } echo "Thank you for subscribing to the JSay Newsletter. We look forward to keeping you up to date with what's happening on JSay and in your community.";mysql_close($con) ?> Thanks for your help... Quote Link to comment Share on other sites More sharing options...
artacus Posted February 9, 2007 Share Posted February 9, 2007 Because now instead of a break, you've got a space... spaceman. Quote Link to comment Share on other sites More sharing options...
poleman Posted February 9, 2007 Author Share Posted February 9, 2007 thank you!!! it works now Now, how can i can get it to redirect to a url page instead of having a white page with just that thank you message on it? Would like it to redirect to www.jsay.co.uk/newsletter_thankyou Any ideas? thanks for all your help... this has been driving me nuts all night Quote Link to comment Share on other sites More sharing options...
artacus Posted February 9, 2007 Share Posted February 9, 2007 header ('Location: http://www.jsay.co.uk...'); Quote Link to comment Share on other sites More sharing options...
poleman Posted February 9, 2007 Author Share Posted February 9, 2007 sorry, where exactly should i put the header? Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 9, 2007 Share Posted February 9, 2007 Where you want it to redirect. The header() tells it to go to the Location: Quote Link to comment Share on other sites More sharing options...
poleman Posted February 9, 2007 Author Share Posted February 9, 2007 sure, but where in the code am i to put this header line? sorry for being a bit dumb on this... Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 9, 2007 Share Posted February 9, 2007 Well, if you want it to redirect instead of print out text, put it where you now have it printing out text. Quote Link to comment Share on other sites More sharing options...
poleman Posted February 9, 2007 Author Share Posted February 9, 2007 So the final line will be echo ('Location: http://www.jsay.co.uk...');";mysql_close($con) ?> right? Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 9, 2007 Share Posted February 9, 2007 No. Do it exactly like artacus posted. No echo. Any code after a redirection will not be run. You also need to stop putting more than one statement per line, that's going to get confusing. in this case it looks like header() will be the last line of code. Quote Link to comment Share on other sites More sharing options...
artacus Posted February 9, 2007 Share Posted February 9, 2007 Spaceman, you've got to try these things on your own, or you're never going to learn. Try it, and tweak it until it works, if you still cant get it, then ask more questions. 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.