Good time.

Now I worked with the base and was puzzled with the question:

$db_res = sqlite_open( $db_name ) || die ("Ошибка при открытии БД!" ); $query = sqlite_query($db_res, "SELECT * FROM $table") || die ('Ошибка в запросе!'); 

When using "|| die ()" I get an error

Warning: sqlite_query() expects parameter 1 to be resource, string given in ... on line ...
Ошибка в запросе!

If you change the operator "||" on "or" everything works correctly, why?

    2 answers 2

    The fact is that the operator || has a higher priority than the operator = , therefore the result of the expression sqlite_open( $db_name ) || die ("Ошибка при открытии БД!" ) sqlite_open( $db_name ) || die ("Ошибка при открытии БД!" ) , i.e. true

    Operator or vice versa has a lower priority than = , therefore, first $db_res will be assigned the result sqlite_open( $db_name ) and then the logical OR will be applied: $db_res || die ("Ошибка при открытии БД!" ) $db_res || die ("Ошибка при открытии БД!" )

    Those. if you prioritize explicitly, both expressions will look like this:

     $db_res = ( sqlite_open( $db_name ) || die ("Ошибка при открытии БД!" ) ); ( $db_res = sqlite_open( $db_name ) ) or die ("Ошибка при открытии БД!" ); 
    • Ok, thanks, now everything is clear. - Afipsky

    And programming agreements talk about the priority of using the OR and AND operators before || and &&. So I advise you to use the literal version.