weetabix Posted December 4, 2007 Share Posted December 4, 2007 Ok first of all hi all im new and im in desperate need of some help as i have a project due tomorrow. I've got this table which I want to add data to it. I wrote the following code, tried it a million times but it doesnt seem to add anything to my database. Any help is appreciated. Form Code Here function show_form(){ ?> <form action="addStaff.php" method="post"> <p> Staff ID: <input type = "Text" name="staffid"> <br> Username: <input type = "Text" name="username"> <br> Password: <input type = "Text" name="password"> <br> Telephone: <input type = "Text" name="telephone"> <br> E-Mail: <input type = "Text" name="email"> <br> First Name: <input type = "Text" name="firstname"> <br> Last Name: <input type = "Text" name="surname"> <br> Address: <input type = "Text" name="address"> <br> Postcode: <input type = "Text" name="postcode"> <br> Hours per week: <input type = "Text" name="workhrs"> <br> Position ID: <input type = "Number" name = "positionid"> Role <input type = "Text" name="role"> <br> <input type= "Submit" name="submit" value= "Submit"> </form> <?PHP } Insertion code $staff_id = $_POST['staffid']; $username = $_POST['username']; $password = $_POST['password']; $telephone = $_POST['telephone']; $email = $_POST['email']; $first_name = $_POST['firstname']; $last_name = $_POST['surname']; $address = $_POST['address']; $postcode = $_POST['postcode']; $hours_per_week = $_POST['workhrs']; $position_id = $_POST['positionid']; $role = $_POST['role']; $query = "INSERT INTO Staff (staff_id,username,password,telephone,email,first_name,last_name,address,postcode,hours_per_week,position_id,role) VALUES ('$staff_id', '$username', '$password', '$telephone', '$email', '$first_name', '$last_name', '$address', '$postcode', '$hours_per_week', '$position_id', '$role')"; $results = mysql_query($query); echo 'Data Saved!'; mysql_close($connection); I know its connecting to the database properly but it wont let me save it Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 4, 2007 Share Posted December 4, 2007 Try this please Change $results = mysql_query($query); to $results = mysql_query($query) or die(mysql_error()); And tell me if you get any errors. Quote Link to comment Share on other sites More sharing options...
weetabix Posted December 4, 2007 Author Share Posted December 4, 2007 Unknown column 'telephone' in 'field list' Yeah I guess apparently I was dumb enough not to notice that it's telephone_no in the Table works like a charm now, thanks a million!! Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 4, 2007 Share Posted December 4, 2007 Unknown column 'telephone' in 'field list' Yeah I guess apparently I was dumb enough not to notice that it's telephone_no in the Table works like a charm now, thanks a million!! Yup, no problem. Please click Topic Solved if it isnt too much to ask lol Quote Link to comment Share on other sites More sharing options...
weetabix Posted December 4, 2007 Author Share Posted December 4, 2007 i did it right away! apparently you're too fast for me lol 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.