View Single Post
02-11-2005, 03:01 PM
#1
DateinaDash is offline DateinaDash
Status: The BidMaster
Join date: Nov 2004
Location: England
Expertise:
Software:
 
Posts: 10,821
iTrader: 0 / 0%
 

DateinaDash is on a distinguished road

  Old  php adding duplicate data, help needed :)

Hey everyone, i have a script and for some reason it's adding the same information twice (even though i'm submitting it only once via a form).

Please review my code and see where i'm going wrong! Thanks



$type=$HTTP_POST_VARS['type'];
$price=$HTTP_POST_VARS['price'];
$bedrooms=$HTTP_POST_VARS['bedrooms'];
$location=$HTTP_POST_VARS['location'];

if (!$type || !$price || !$bedrooms || !$location)
{
echo 'You have not entered all the required details.<br />'
.'Please go back and try again.';
exit;
}

$db = mysql_pconnect('localhost', 'talkfreelance', 'password');

if (!$db)
{
echo 'Error: Could not connect to database. Please try again later.';
exit;
}

mysql_select_db('talkfreelance_com_-_3') or die(mysql_error());

$query = "INSERT INTO property VALUES ('', '$type','$price','$bedrooms','$location')";
mysql_query($query);

$result = mysql_query($query) or die(mysql_error());

if ($result)
echo mysql_affected_rows().' property inserted into database.';
?>