DeathsRHM
07-21-2008, 02:01 PM
Right, if you are using PHP to enter data into an SQL table, how exactly does it work?
I used this:
<?php
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con);
mysql_query("INSERT INTO person (FirstName, LastName, Age)
VALUES ('Peter', 'Griffin', '35')");
mysql_query("INSERT INTO person (FirstName, LastName, Age)
VALUES ('Glenn', 'Quagmire', '33')");
mysql_close($con);
?>
And it adds the records, but wouldnt it add the same record every time i opened the page? and if I put primary key, wouldnt it come up with an error every time after the first time i opened the page?
An explaination would be helpful, thanks, and if the php code i inserted needs changing, tell me please ;)
I used this:
<?php
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con);
mysql_query("INSERT INTO person (FirstName, LastName, Age)
VALUES ('Peter', 'Griffin', '35')");
mysql_query("INSERT INTO person (FirstName, LastName, Age)
VALUES ('Glenn', 'Quagmire', '33')");
mysql_close($con);
?>
And it adds the records, but wouldnt it add the same record every time i opened the page? and if I put primary key, wouldnt it come up with an error every time after the first time i opened the page?
An explaination would be helpful, thanks, and if the php code i inserted needs changing, tell me please ;)