I have two insert statements. The second one will be executed only after successful execution of first one. What I would like to do is:
$sqlone="Insert into .....";
$sqltwo="Insert into.....";
If (mysql_query($sqlone))
{
If (mysql_query($sqltwo))
{
Show message Data inserted in both tables.
}
}
Try this
$query1 = '...';
$query2 = '...';
$query3 = '...';
if(mysql_query($query1)) {
if(mysql_query($query2)) {
if(mysql_query($query3)) {
echo "success";
}
else { echo "error"; }
}
else { echo "error"; }
}
else { echo "error"; }
Sounds like you're looking for transactions.
A bit of googling gave me some info on database transactions in PHP - hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With