PHP Novice question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael Jones

    PHP Novice question

    I m getting a parse error on this snipet of code and I can't understand why:

    for ($i=0; i$ < $num_results; $i++)
    {
    $row = mysql_fetch_row ($result)
    echo $row[1];
    }

    It doesn't like the for statement, and it doesn't like the echo $row[1];
    I am typing it right out of the manual. What am I doing wrong?
  • Urs Weder

    #2
    Re: PHP Novice question

    Michael Jones wrote:[color=blue]
    > I m getting a parse error on this snipet of code and I can't understand why:
    >
    > for ($i=0; i$ < $num_results; $i++)[/color]
    ---- should be '$i' instead of 'i$'[color=blue]
    > {
    > $row = mysql_fetch_row ($result)[/color]
    -- where is ';'?[color=blue]
    > echo $row[1];
    > }
    >
    > It doesn't like the for statement, and it doesn't like the echo $row[1];
    > I am typing it right out of the manual. What am I doing wrong?[/color]

    Comment

    • Andy Hassall

      #3
      Re: PHP Novice question

      On 2 Jul 2004 14:17:29 -0700, michaelraymond_ 2000@yahoo.com (Michael Jones)
      wrote:
      [color=blue]
      >I m getting a parse error on this snipet of code and I can't understand why:
      >
      > for ($i=0; i$ < $num_results; $i++)
      > {
      > $row = mysql_fetch_row ($result)
      > echo $row[1];
      > }
      >
      >It doesn't like the for statement, and it doesn't like the echo $row[1];
      >I am typing it right out of the manual. What am I doing wrong?[/color]

      Which part of the manual?
      What error are you getting?
      Which line does it refer to?

      One mistake is on the first line:
      [color=blue]
      > for ($i=0; i$ < $num_results; $i++)[/color]
      ^^

      You mean $i not i$.

      (Hm - takes me back to years ago when I was playing with STOS Basic - still
      read i$ as 'i' 'string').

      --
      Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
      http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space

      Comment

      • Tom Thackrey

        #4
        Re: PHP Novice question


        On 2-Jul-2004, michaelraymond_ 2000@yahoo.com (Michael Jones) wrote:
        [color=blue]
        > I m getting a parse error on this snipet of code and I can't understand
        > why:
        >
        > for ($i=0; i$ < $num_results; $i++)
        > {
        > $row = mysql_fetch_row ($result)
        > echo $row[1];
        > }
        >
        > It doesn't like the for statement, and it doesn't like the echo $row[1];
        > I am typing it right out of the manual. What am I doing wrong?[/color]

        Read the manual more carefully. You are missing a ; at the end of the
        mysql_fetch_row () line.

        --
        Tom Thackrey

        tom (at) creative (dash) light (dot) com
        do NOT send email to jamesbutler@wil lglen.net (it's reserved for spammers)

        Comment

        • Michael Jones

          #5
          Re: PHP Novice question

          Thank you SOOO much everyone!!

          "Tom Thackrey" <use.signature@ nospam.com> wrote in message news:<%%nFc.545 7$Vh1.4013@news svr25.news.prod igy.com>...[color=blue]
          > On 2-Jul-2004, michaelraymond_ 2000@yahoo.com (Michael Jones) wrote:
          >[color=green]
          > > I m getting a parse error on this snipet of code and I can't understand
          > > why:
          > >
          > > for ($i=0; i$ < $num_results; $i++)
          > > {
          > > $row = mysql_fetch_row ($result)
          > > echo $row[1];
          > > }
          > >
          > > It doesn't like the for statement, and it doesn't like the echo $row[1];
          > > I am typing it right out of the manual. What am I doing wrong?[/color]
          >
          > Read the manual more carefully. You are missing a ; at the end of the
          > mysql_fetch_row () line.[/color]

          Comment

          • Mudge

            #6
            Re: PHP Novice question

            Michael Jones wrote:
            [color=blue]
            > I m getting a parse error on this snipet of code and I can't understand
            > why:
            >
            > for ($i=0; i$ < $num_results; $i++)
            > {
            > $row = mysql_fetch_row ($result)
            > echo $row[1];
            > }
            >
            > It doesn't like the for statement, and it doesn't like the echo $row[1];
            > I am typing it right out of the manual. What am I doing wrong?[/color]

            Hey, I hope that you come back and read this Michael. You seem like a dorky
            new programmer. I am too. I need some PHP buddies. What are you
            learning PHP for?


            Comment

            Working...