Jump to content

Man I really need help! insert into sql table big problem.


11Tami

Recommended Posts

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 version
4.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>
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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.