hi all! lame programmer here again.Please explain this thing..seems like it has truth table and stuf.anding oring etc..plz explain how this will execute.need simple explanation so i wont forget throughout my life..:D

if (!(mysql_query($sql,$con)) || !(mysql_query($sql_pin,$con)))
    {
    if(mysql_errno()==1062)
        {
               $error_flag=1; 
               echo mysql_error();
                echo "error no:".mysql_errno();
                 die("error:".mysql_errno());
          }
                $error_flag=1;
        }
        else
        $error_flag=0;

The script is checking for errors, if there is no errors then it kills it self before it enters the first statement. If there is an error then it checks to see if the error number matches error 1062 (has to be exact notice the == ) if this passes then it chanegs the bool to true (1) on error_flag and echos out the error number then kills the script. If its not error 1062 it just changes the error flag to 1 and outputs nothing. Seems trvial to me and prob for a class. Study harder :-P

i wanted to know more about the execution of the first if statement where there is condition with || OR sign.i wanted to know true true false false stuff..if it is applicable in php and this ultimately in this first if statement. :)

if (!(mysql_query($sql,$con)) || !(mysql_query($sql_pin,$con)))
    {
    if(mysql_errno()==1062)
        {
               $error_flag=1; 
               echo mysql_error();
                echo "error no:".mysql_errno();
                 die("error:".mysql_errno());
          }
                $error_flag=1;
        }
        else
        $error_flag=0;

If mysql_query($sql,$con) returns false OR mysql_query($sql_pin,$con) returns false then check if mysql_errno() is equal to 1062.

If it is equal to 1062 set $error_flag = 1; and echo mysql_error(); and echo "error no:".mysql_errno(); and finally die("error:".mysql_errno());

If mysql_errno() doesnt equal 1062 set $error_flag = 1;

If mysql_query($sql,$con) and mysql_query($sql_pin,$con) both evaluate to true set $error_flag = 0;

The first statement is looking at a sql query mysql_query($sql,$con) and mysql_query($sql_pin,$conn). the first part the $sql or $sql_pin are both sql queries contained. The second part $con is the connection. Bascially what the if statement is testing is to see if the query works. If any errors at all are brought up as the php queries the server, such as incorrect syntax stored in that query variable. If any errors then the if statement holds as true!. If the query runs with no hitches then it held as false. if either or both of these queries fail then it doesnt run. Because your using the OR operator only one of the two queries have to fail, not both. If they both work then none of the code below in the brackets is executed.

Understand? Its overall quite simple :)

Be a part of the DaniWeb community

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