steve490 Posted December 22, 2009 Share Posted December 22, 2009 Hey im not sure whether this is in the wrong section but here goes, I have a problem with some code that doesn't seem to be inserting data from a form on my website to a database. I've tried so many different ways to do this the code might be untidy. i'm a bit of a noob so go easy on me haha sign_up is the DB name and signup is the table name just to clarify heres the code $email = $_POST{"email"}; $firstName = $_POST{"firstName"}; $surname = $_POST {"surname"}; $DOB = $_POST {"DOB"}; $University = $_POST {"University"}; $Art_specialty = $_POST {"Art_specialty"}; $dbhost = 'localhost'; $dbuser = 'user'; $dbpass = 'pass'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'webcatc1_signup'; mysql_select_db($dbname); mysql_query("INSERT INTO sign_up (email, firstName, surname, DOB, University, Art_specialty) VALUES (".$email.",".$firstName.",".$surname.",".$DOB.",".$University.",".$Art_specialty.")"); $result = mysql_query("SELECT * FROM sign_up") or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo $row['firstName']. " - ". $row['surname']; echo "<br />"; } echo "the results are..." .$email. "" .$firstName; echo "1 record added"; mysql_close($conn) Thanks for the help Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 22, 2009 Share Posted December 22, 2009 you do not have quotes on your insert values since it is a string it should have quotes something like this mysql_query("INSERT INTO sign_up (email, firstName, surname, DOB, University, Art_specialty) VALUES ('".$email."','".$firstName."','".$surname."','".$DOB."','".$University."','".$Art_specialty."')"); Quote Link to comment Share on other sites More sharing options...
steve490 Posted December 22, 2009 Author Share Posted December 22, 2009 Cheers that was quick and simple will remember how to do it now problem solved 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.