$query = mysql_query($sql) or die("$sql_error" . mysql_error());

this is what i am using to generate an error if the MySQL query fails, but instead of generating an error and die'ing, i want to assign data to a variable and keep the script running....

so if I wanted to $query = mysql_query($sql) OR $variable = 1;

how would i code that properly? I am getting a syntax error...

thanks!

    Precedence:

    ($query = mysql_query($sql)) or ($variable = 1);

    Remember to set $variable to something first, otherwise it won't be set if the query succeeds - and if you then try to use $variable you'd get an Undefined Variable notice.

    Also, the first pair of parentheses isn't really necessary, but it makes it clearer what's going on.

    If you want to be really clear about it, though...

    if(!($query = mysql_query($sql)))
    {
        $variable = 1;
    }
      Write a Reply...