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. :)