11Tami Posted October 1, 2006 Share Posted October 1, 2006 I've been working on this for several days. I don't know why its so hard! Trying to add a simple entry to a my sql table. server version4.0.27 database name "dropdown" table name "buttons" column name "one" I sure hope someone can help, thanks! Tami<?php$con = mysql_connect("","dropdown","");if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("dropdown", $con);$firstname = $_POST['firstname'] ; $sql="INSERT INTO buttons (one)VALUES('$_POST[firstname]')";if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); }echo "1 record added";mysql_close($con)?>input field name is "firstname"<form action="http://www.website.com/dropdown.php" method="post">first name<input type="text" name="firstname" /><input type="submit"/></form> Quote Link to comment https://forums.phpfreaks.com/topic/22640-man-i-really-need-help-insert-into-sql-table-big-problem/ Share on other sites More sharing options...
.josh Posted October 1, 2006 Share Posted October 1, 2006 Hi Tami,Are you getting any errors displayed? Can you give a description of what's "wrong?" Quote Link to comment https://forums.phpfreaks.com/topic/22640-man-i-really-need-help-insert-into-sql-table-big-problem/#findComment-101706 Share on other sites More sharing options...
JasonLewis Posted October 1, 2006 Share Posted October 1, 2006 from just looking at the php code. try replaceing it with this. but i am not sure because you didn't give any errors. but just try this:[code]<?php$con = mysql_connect("","dropdown","");if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("dropdown", $con);$firstname = $_POST['firstname'] ; $sql="INSERT INTO `buttons` (`one`)VALUES('".$_POST['firstname']."')";if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); }echo "1 record added";mysql_close($con)?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/22640-man-i-really-need-help-insert-into-sql-table-big-problem/#findComment-101724 Share on other sites More sharing options...
Barand Posted October 1, 2006 Share Posted October 1, 2006 [code]$con = mysql_connect("","dropdown","");[/code]mysql_connect() arguments are hostnameusernamepassword Quote Link to comment https://forums.phpfreaks.com/topic/22640-man-i-really-need-help-insert-into-sql-table-big-problem/#findComment-101774 Share on other sites More sharing options...
otuatail Posted October 1, 2006 Share Posted October 1, 2006 If the field name is firstname then it should be$sql="INSERT INTO buttons (firstname ) VALUES ($_POST[firstname])";Des. Quote Link to comment https://forums.phpfreaks.com/topic/22640-man-i-really-need-help-insert-into-sql-table-big-problem/#findComment-101792 Share on other sites More sharing options...
11Tami Posted October 1, 2006 Author Share Posted October 1, 2006 Thank you, thank you, thank you, lord project fear! Weird thing is It worked once with what I had but then it would never work again. That made no sense to me. Project fear yours works just fine! Thank you very much! Quote Link to comment https://forums.phpfreaks.com/topic/22640-man-i-really-need-help-insert-into-sql-table-big-problem/#findComment-101897 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.