0

Can you help me with this program?. I am trying to insert data into two mysql tables at once. I have two tables: property and personal.

<?php
define('DB_NAME', 'purchase');
define('DB_USER', 'root');
define('DB_PASSWORD', 'root');
define('DB_HOST', 'localhost');

$connection = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);

if (!$connection) {
    die('Could not connect: ' . mysql_error());
}

$result = mysql_select_db(DB_NAME, $connection);

if (!$result) {
    die('Can\'t use ' . DB_NAME . ': ' . mysql_error());
}

echo 'Connected successfully';

$typepay = $_POST['typepay'];

$buyertype = $_POST['buyertype'];


$sql = "INSERT INTO property (typepay)". 
"VALUES". 
"('$typepay')";


$sql = "INSERT INTO personal". 
"(buyertype)". 
"VALUES". 
"('$buyertype')";



if (!mysql_query($sql)) {
    die('Error: ' . mysql_error());
}

mysql_close();

?>

Thank for the answers. :)

2
Contributors
4
Replies
18
Views
2 Years
Discussion Span
Last Post by jorwill.harion
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.