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.

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

$sql = "INSERT INTO personal". 

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



Thank for the answers. :)

Line 31 overwrites line 26. In between you should have what's on line 38.

I did that but the data is only accessing the property table.

Do you get an error?

hey!it's working.thank you so save my brain from exploding! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.