Jump to content

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


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]
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.