Zend Studio calling something valid a bug...or IS it a bug?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • news@celticbear.com

    #1

    Zend Studio calling something valid a bug...or IS it a bug?

    I have lines of code that look like this:

    while ($row2sx = mysql_fetch_arr ay($result2sx)) {

    Now that's the way I've always learned to create an array from a mySQL
    querey.

    I just started trying the Zend Studio (and to be honest, except for the
    debugger I'm seeing that it has less features than EditPlus.)
    And the debugger calls all my WHERE() functions bugged because I'm
    using one = instead of two as in ==.

    a) Is there a better way of formatting a mysql_fetch_arr ay, or
    b) Is there a way to tell Zend Studio that hey, that's a-ok code?
    (I haven't been able to find an option to allow that.)

    While on the subject, I'll have includes like this:
    include_once("i ncludes/connect.php");
    which will have in it lines that establish variables like:
    $dbh=mysql_conn ect ("localhost" , "username", "password") or die ('I
    cannot connect to the database because: ' . mysql_error());

    but in the main page it will say $dbh in the line:
    $result_home_fe ature = @mysql_query($s ql_home_feature , $dbh);
    is an error because $dbh is being used before it's defined.
    Yet, in the little Studio file list of included files it shows the
    connect.php file that establishes what $dbh is.

    Is there something that needs to be set that I can't find for it to
    recognize its...set-ness?

    Thanks for any help!
    Liam

  • Kevin Lin

    #2
    Re: Zend Studio calling something valid a bug...or IS it a bug?

    What version of Zend are you using? Is it giving you an error message or
    showing you the red "bad syntax squiggle". My version of ZS doesn't compain
    about the sample line you gave when I drop into a script, nor does it
    complain if variables are defined in includes.

    - Kevin

    <news@celticbea r.com> wrote in message
    news:1102625014 .181538.53390@z 14g2000cwz.goog legroups.com...[color=blue]
    > I have lines of code that look like this:
    >
    > while ($row2sx = mysql_fetch_arr ay($result2sx)) {
    >
    > Now that's the way I've always learned to create an array from a mySQL
    > querey.
    >
    > I just started trying the Zend Studio (and to be honest, except for the
    > debugger I'm seeing that it has less features than EditPlus.)
    > And the debugger calls all my WHERE() functions bugged because I'm
    > using one = instead of two as in ==.
    >
    > a) Is there a better way of formatting a mysql_fetch_arr ay, or
    > b) Is there a way to tell Zend Studio that hey, that's a-ok code?
    > (I haven't been able to find an option to allow that.)
    >
    > While on the subject, I'll have includes like this:
    > include_once("i ncludes/connect.php");
    > which will have in it lines that establish variables like:
    > $dbh=mysql_conn ect ("localhost" , "username", "password") or die ('I
    > cannot connect to the database because: ' . mysql_error());
    >
    > but in the main page it will say $dbh in the line:
    > $result_home_fe ature = @mysql_query($s ql_home_feature , $dbh);
    > is an error because $dbh is being used before it's defined.
    > Yet, in the little Studio file list of included files it shows the
    > connect.php file that establishes what $dbh is.
    >
    > Is there something that needs to be set that I can't find for it to
    > recognize its...set-ness?
    >
    > Thanks for any help!
    > Liam
    >[/color]


    Comment

    • LRW

      #3
      Re: Zend Studio calling something valid a bug...or IS it a bug?

      (top post :-P *grin*)
      Thanks for replying!
      I'm using Zend Studio 3.5.2 Plus.
      Unfortunately the error it gives me down in the bottom right window is an
      image, and not text, or I'd cut and paste it.
      I'll just retype it here:

      For the $dbh example=
      "Category: Security
      Description:
      A global variable is used before it is defined. You may see this warning if
      you rely on register_global s or variables defined in external include files,
      in which you may chose to ignore it. However, note that this may cause the
      code to behave in unpredictable ways when run in certain contexts."

      The while ($row_hfeat = mysql_fetch_arr ay($result_home _feature)) { example:
      "Category: Bug
      Description:
      Assignments in a conditional statement are sometimes the result of a typo.
      In many cases, instead of the assigned operator =, the equality operator ==
      should be used...."

      Thanks!
      Liam


      "Kevin Lin" <kevin@wx3REMOV E4SPAM.com> wrote in message
      news:ig3ud.4705 57$wV.258233@at tbi_s54...[color=blue]
      > What version of Zend are you using? Is it giving you an error message or
      > showing you the red "bad syntax squiggle". My version of ZS doesn't
      > compain
      > about the sample line you gave when I drop into a script, nor does it
      > complain if variables are defined in includes.
      >
      > - Kevin
      >
      > <news@celticbea r.com> wrote in message
      > news:1102625014 .181538.53390@z 14g2000cwz.goog legroups.com...[color=green]
      >> I have lines of code that look like this:
      >>
      >> while ($row2sx = mysql_fetch_arr ay($result2sx)) {
      >>
      >> Now that's the way I've always learned to create an array from a mySQL
      >> querey.
      >>
      >> I just started trying the Zend Studio (and to be honest, except for the
      >> debugger I'm seeing that it has less features than EditPlus.)
      >> And the debugger calls all my WHERE() functions bugged because I'm
      >> using one = instead of two as in ==.
      >>
      >> a) Is there a better way of formatting a mysql_fetch_arr ay, or
      >> b) Is there a way to tell Zend Studio that hey, that's a-ok code?
      >> (I haven't been able to find an option to allow that.)
      >>
      >> While on the subject, I'll have includes like this:
      >> include_once("i ncludes/connect.php");
      >> which will have in it lines that establish variables like:
      >> $dbh=mysql_conn ect ("localhost" , "username", "password") or die ('I
      >> cannot connect to the database because: ' . mysql_error());
      >>
      >> but in the main page it will say $dbh in the line:
      >> $result_home_fe ature = @mysql_query($s ql_home_feature , $dbh);
      >> is an error because $dbh is being used before it's defined.
      >> Yet, in the little Studio file list of included files it shows the
      >> connect.php file that establishes what $dbh is.
      >>
      >> Is there something that needs to be set that I can't find for it to
      >> recognize its...set-ness?
      >>
      >> Thanks for any help!
      >> Liam
      >>[/color]
      >
      >[/color]


      Comment

      • Kevin Lin

        #4
        Re: Zend Studio calling something valid a bug...or IS it a bug?

        Okay, I see what you're talking about now-- Zend's "code analyzer" tool.

        I'd consider it's reports suggestions of things you might want to fix.
        Assignments in conditions are fine for the way you're using them. It's
        trying to warn you away from this common mistake: "if ($user_id = 'admin')
        {...}"

        As for the $dbh variable, I'm not sure why it doesn't pick that it's getting
        assigned in your include file. It seems to recognize defines okay.


        "LRW" <deja@celticbea r.com> wrote in message
        news:mw6ud.2323 75$R05.10431@at tbi_s53...[color=blue]
        > (top post :-P *grin*)
        > Thanks for replying!
        > I'm using Zend Studio 3.5.2 Plus.
        > Unfortunately the error it gives me down in the bottom right window is an
        > image, and not text, or I'd cut and paste it.
        > I'll just retype it here:
        >
        > For the $dbh example=
        > "Category: Security
        > Description:
        > A global variable is used before it is defined. You may see this warning[/color]
        if[color=blue]
        > you rely on register_global s or variables defined in external include[/color]
        files,[color=blue]
        > in which you may chose to ignore it. However, note that this may cause the
        > code to behave in unpredictable ways when run in certain contexts."
        >
        > The while ($row_hfeat = mysql_fetch_arr ay($result_home _feature)) {[/color]
        example:[color=blue]
        > "Category: Bug
        > Description:
        > Assignments in a conditional statement are sometimes the result of a typo.
        > In many cases, instead of the assigned operator =, the equality operator[/color]
        ==[color=blue]
        > should be used...."
        >
        > Thanks!
        > Liam
        >
        >
        > "Kevin Lin" <kevin@wx3REMOV E4SPAM.com> wrote in message
        > news:ig3ud.4705 57$wV.258233@at tbi_s54...[color=green]
        > > What version of Zend are you using? Is it giving you an error message[/color][/color]
        or[color=blue][color=green]
        > > showing you the red "bad syntax squiggle". My version of ZS doesn't
        > > compain
        > > about the sample line you gave when I drop into a script, nor does it
        > > complain if variables are defined in includes.
        > >
        > > - Kevin
        > >
        > > <news@celticbea r.com> wrote in message
        > > news:1102625014 .181538.53390@z 14g2000cwz.goog legroups.com...[color=darkred]
        > >> I have lines of code that look like this:
        > >>
        > >> while ($row2sx = mysql_fetch_arr ay($result2sx)) {
        > >>
        > >> Now that's the way I've always learned to create an array from a mySQL
        > >> querey.
        > >>
        > >> I just started trying the Zend Studio (and to be honest, except for the
        > >> debugger I'm seeing that it has less features than EditPlus.)
        > >> And the debugger calls all my WHERE() functions bugged because I'm
        > >> using one = instead of two as in ==.
        > >>
        > >> a) Is there a better way of formatting a mysql_fetch_arr ay, or
        > >> b) Is there a way to tell Zend Studio that hey, that's a-ok code?
        > >> (I haven't been able to find an option to allow that.)
        > >>
        > >> While on the subject, I'll have includes like this:
        > >> include_once("i ncludes/connect.php");
        > >> which will have in it lines that establish variables like:
        > >> $dbh=mysql_conn ect ("localhost" , "username", "password") or die ('I
        > >> cannot connect to the database because: ' . mysql_error());
        > >>
        > >> but in the main page it will say $dbh in the line:
        > >> $result_home_fe ature = @mysql_query($s ql_home_feature , $dbh);
        > >> is an error because $dbh is being used before it's defined.
        > >> Yet, in the little Studio file list of included files it shows the
        > >> connect.php file that establishes what $dbh is.
        > >>
        > >> Is there something that needs to be set that I can't find for it to
        > >> recognize its...set-ness?
        > >>
        > >> Thanks for any help!
        > >> Liam
        > >>[/color]
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Michael Schmid

          #5
          Re: Zend Studio calling something valid a bug...or IS it a bug?

          [color=blue]
          > while ($row2sx = mysql_fetch_arr ay($result2sx)) {[/color]

          is no "good"

          $row2sx = mysql_fetch_arr ay($result2sx)
          while ($row2sx) {
          // ....
          $row2sx = mysql_fetch_arr ay($result2sx)

          would be correct, but i do it as you do

          Comment

          Working...