Add two functions after OR statement

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

    Add two functions after OR statement

    [php]$sql = mysql_query($qu ery) or die('Error retrieving data.');[/php]

    I want to run a function before die('Error retrieving data.'). Can anyone tell me the syntax how to do that?
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Originally posted by hsriat
    [php]$sql = mysql_query($qu ery) or die('Error retrieving data.');[/php]I want to run a function before die('Error retrieving data.'). Can anyone tell me the syntax how to do that?
    You can do it within the IF block, i.e.
    [php]
    if (!$sql = mysql_query($qu ery)) {
    // do what ever you want
    die('Error retrieving data.');
    }
    [/php]
    Ronald

    Comment

    • hsriat
      Recognized Expert Top Contributor
      • Jan 2008
      • 1653

      #3
      Originally posted by hsriat
      [php]$sql = mysql_query($qu ery) or die('Error retrieving data.');[/php]

      I want to run a function before die('Error retrieving data.'). Can anyone tell me the syntax how to do that?
      I got the solution,

      'and'

      [php]$sql = mysql_query($qu ery) or error_given(45) and die('Error retrieving data.');[/php]

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        That was a close finish. See you next time.

        Ronald

        Comment

        • hsriat
          Recognized Expert Top Contributor
          • Jan 2008
          • 1653

          #5
          Originally posted by ronverdonk
          That was a close finish. See you next time.

          Ronald

          Yeah :)
          Thanks for trying. :)

          Comment

          Working...