Weird parse error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alvaro G Vicario

    Weird parse error

    The following code produces a parse error:

    $res=mysql_quer y($sql) or return('There was an error');

    However, this works fine:

    $res=mysql_quer y($sql) or die('There was an error');

    I can't understand why. In case of SQL error I only want to stop executing
    current function, not the whole script.


    --
    --
    -- Álvaro G. Vicario - Burgos, Spain
    --
  • michel

    #2
    Re: Weird parse error

    if(!$res=mysql_ query($sql)) return("There was an error");

    Denada,

    Michel

    "Alvaro G Vicario" <alvaro_QUITAR_ REMOVE@telecomp uteronline.com> wrote in
    message news:l6zhxxzo5q 8x.10nh8e759h1z y.dlg@40tude.ne t...[color=blue]
    > The following code produces a parse error:
    >
    > $res=mysql_quer y($sql) or return('There was an error');
    >
    > However, this works fine:
    >
    > $res=mysql_quer y($sql) or die('There was an error');
    >
    > I can't understand why. In case of SQL error I only want to stop executing
    > current function, not the whole script.
    >
    >
    > --
    > --
    > -- Álvaro G. Vicario - Burgos, Spain
    > --[/color]


    Comment

    • Chung Leong

      #3
      Re: Weird parse error

      "Alvaro G Vicario" <alvaro_QUITAR_ REMOVE@telecomp uteronline.com> wrote in
      message news:l6zhxxzo5q 8x.10nh8e759h1z y.dlg@40tude.ne t...[color=blue]
      > The following code produces a parse error:
      >
      > $res=mysql_quer y($sql) or return('There was an error');
      >
      > However, this works fine:
      >
      > $res=mysql_quer y($sql) or die('There was an error');
      >
      > I can't understand why. In case of SQL error I only want to stop executing
      > current function, not the whole script.
      >
      >
      > --
      > --
      > -- Álvaro G. Vicario - Burgos, Spain
      > --[/color]

      return is a operator, that's why. Same thing would happen if you do " ... or
      echo $error."


      Comment

      • Alvaro G Vicario

        #4
        Re: Weird parse error

        *** Chung Leong wrote/escribió (Tue, 15 Jun 2004 18:07:32 -0400):[color=blue]
        > return is a operator, that's why. Same thing would happen if you do " ... or
        > echo $error."[/color]

        You are right: it happens with echo, exit... I didn't have the faintest
        idea that you couldn't use them this way.


        --
        --
        -- Álvaro G. Vicario - Burgos, Spain
        --

        Comment

        Working...