what is error in this line of code?

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

    what is error in this line of code?

    The following code snippet gives an error "unexpected '}'"

    I have tried chopping up the line into small parts and it seems to die
    when I get the the "onclick" part of the line.

    Can anyone see what the problem is or offer a suggestion on how to do
    this better.

    Thanks!

    Mike

  • Fivestar

    #2
    Re: what is error in this line of code?

    might help if I posted the code :) The line in question is the long
    print line

    while ($line = mysql_fetch_ass oc($pics)) {
    $num = $line["SeqNo"];
    $name = $line["Name"];
    print "<p>$num $name</p>";
    print "<p align=\"left\"> <a style=\"cursor: hand\"
    onclick=\"chgpi c($num)\"><font color="#FFFFFF" >$name</font></a></p>";
    }

    Comment

    • Chris Hope

      #3
      Re: what is error in this line of code?

      Fivestar wrote:
      [color=blue]
      > might help if I posted the code :) The line in question is the long
      > print line
      >
      > while ($line = mysql_fetch_ass oc($pics)) {
      > $num = $line["SeqNo"];
      > $name = $line["Name"];
      > print "<p>$num $name</p>";
      > print "<p align=\"left\"> <a style=\"cursor: hand\"
      > onclick=\"chgpi c($num)\"><font color="#FFFFFF" >$name</font></a></p>";
      > }[/color]

      <font color="#FFFFFF" >

      should be

      <font color=\"#FFFFFF \">

      --
      Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/

      Comment

      • noSpam

        #4
        Re: what is error in this line of code?

        Fivestar wrote:[color=blue]
        > might help if I posted the code :) The line in question is the long
        > print line
        >
        > while ($line = mysql_fetch_ass oc($pics)) {
        > $num = $line["SeqNo"];
        > $name = $line["Name"];
        > print "<p>$num $name</p>";
        > print "<p align=\"left\"> <a style=\"cursor: hand\"
        > onclick=\"chgpi c($num)\"><font color="#FFFFFF" >$name</font></a></p>";
        > }
        >[/color]
        The immediate thing that springs to mind is yuo haven't escaped the
        quotes around the colour string

        Comment

        • Michael Fesser

          #5
          Re: what is error in this line of code?

          .oO(Fivestar)
          [color=blue]
          >might help if I posted the code :) The line in question is the long
          >print line
          >
          >while ($line = mysql_fetch_ass oc($pics)) {
          > $num = $line["SeqNo"];
          > $name = $line["Name"];
          > print "<p>$num $name</p>";
          > print "<p align=\"left\"> <a style=\"cursor: hand\"
          >onclick=\"chgp ic($num)\"><fon t color="#FFFFFF" >$name</font></a></p>";
          > }[/color]

          There are some unescaped double quotes in the string, causing the parse
          error. Either escape them or simply use single quotes.

          Micha

          Comment

          • Fivestar

            #6
            Re: what is error in this line of code?

            Chris,

            Thanks for the quick response! Can't believe I missed something that
            obvious!

            Thanks again!

            Mike

            Comment

            • Alvaro G. Vicario

              #7
              Re: what is error in this line of code?

              *** Fivestar escribió/wrote (22 Feb 2005 14:27:16 -0800):[color=blue]
              > Thanks for the quick response! Can't believe I missed something that
              > obvious![/color]

              This kind of errors become pretty obvious when your text editor has syntax
              highlight.

              Also (and this is merely a personal opinion) scaping quotes makes code
              harder to understand:

              print "<p align=\"left\"> <a style=\"cursor: hand\" onclick=\"chgpi c($num)\"><font color="#FFFFFF" >$name</font></a></p>";
              print '<p align="left"><a style="cursor:h and" onclick="chgpic (' . $num. ')"><font color="#FFFFFF" >' . $name . '</font></a></p>';


              --
              -+ Álvaro G. Vicario - Burgos, Spain
              +- http://www.demogracia.com (la web de humor barnizada para la intemperie)
              ++ Manda tus dudas al grupo, no a mi buzón
              -+ Send your questions to the group, not to my mailbox
              --

              Comment

              • Geoff Berrow

                #8
                Re: what is error in this line of code?

                I noticed that Message-ID: <cvgag1$ehn$1@l ust.ihug.co.nz> from Chris
                Hope contained the following:
                [color=blue]
                ><font color="#FFFFFF" >
                >
                >should be
                >[/color]
                removed and replaced by CSS.
                --
                Geoff Berrow (put thecat out to email)
                It's only Usenet, no one dies.
                My opinions, not the committee's, mine.
                Simple RFDs http://www.ckdog.co.uk/rfdmaker/

                Comment

                • Matt Mitchell

                  #9
                  Re: what is error in this line of code?

                  "Geoff Berrow" <blthecat@ckdog .co.uk> wrote in message
                  news:f9en115otb lucocqim5h1lfre t3hftbntm@4ax.c om...

                  : ><font color="#FFFFFF" >
                  : >
                  : >should be
                  : >
                  : removed and replaced by CSS.

                  and then all of it should be removed into a template somewhere ;-)



                  Comment

                  • phiberoptick@gmail.com

                    #10
                    Re: what is error in this line of code?

                    Templates are the only way to go.....

                    Comment

                    • JDS

                      #11
                      Re: what is error in this line of code?

                      On Tue, 22 Feb 2005 14:06:15 -0800, Fivestar wrote:
                      [color=blue]
                      > might help if I posted the code :) The line in question is the long[/color]

                      It also might help if you posted the entire error.

                      --
                      JDS | jeffrey@example .invalid
                      | http://www.newtnotes.com
                      DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/

                      Comment

                      Working...