Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 1494 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

php adding duplicate data, help needed :)

Thread title: php adding duplicate data, help needed :)
     
    Thread tools Search this thread Display Modes  
Prev Previous Post   Next Post Next
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.';
?>

     


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed