bddotnet
10-16-07, 11:54 PM
I have this code.
<HTML>
<HEAD>
<link href="http://www.okfqhr.com/style2.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY>
<?php
$con = mysql_connect("localhost","database","pwd");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}mysql_select_db("database", $con);
$sql="INSERT INTO links (name, url, category)
VALUES
('$_POST[name]','$_POST[url]','$_POST[category]')";if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo '<center><img src="http://www.okfqhr.com/images/head.jpg"><br><p class="sectionheader">1 link added.</p><br><a href="http://www.okfqhr.com/links.php">OkFQHR Links</a>'; mysql_close($con)
?>
</BODY>
</HTML>
Why, when I try to insert a link via a page on my site, do I get the error:
Duplicate entry "person's name" for key 1
The value $name is the primary key. Do I need an ID variable as the primary key to make this work?
PS - The same exact code is used for my announcements page and it works just fine. (with obvious changes of table name and variables, of course).
<HTML>
<HEAD>
<link href="http://www.okfqhr.com/style2.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY>
<?php
$con = mysql_connect("localhost","database","pwd");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}mysql_select_db("database", $con);
$sql="INSERT INTO links (name, url, category)
VALUES
('$_POST[name]','$_POST[url]','$_POST[category]')";if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo '<center><img src="http://www.okfqhr.com/images/head.jpg"><br><p class="sectionheader">1 link added.</p><br><a href="http://www.okfqhr.com/links.php">OkFQHR Links</a>'; mysql_close($con)
?>
</BODY>
</HTML>
Why, when I try to insert a link via a page on my site, do I get the error:
Duplicate entry "person's name" for key 1
The value $name is the primary key. Do I need an ID variable as the primary key to make this work?
PS - The same exact code is used for my announcements page and it works just fine. (with obvious changes of table name and variables, of course).