May 18, 2010

How can I check data has been inserted successfully?

Question by nectar

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.
   }
}

Answer by Starx

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"; }

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!