Parse Errors & Quote Marks

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

    Parse Errors & Quote Marks

    Hi folks,

    I am having trouble identifying the error here can anyone help?

    Parse error: syntax error on line 318

    $e-mail_1 = $_POST['e-mail_1'];

    Also will my use of " " (double quotes) instead of ' ' (single quotes) make
    much difference to the way this code works? It is from a section of code
    that is returning values to a form after it has been validated.

    <tr>
    <td>
    {$label_array['int_code']}
    </td>
    <td>
    <input type="text" class="f_form" name="int_code" value="$int_cod e"
    size="3" title="Internat ional Code: valid characters 0-9, (3 digits)"/>
    </td>
    </tr>

    I am transfering an HTML form in XHTML 1.0 Transitional to php. The book I
    am reading has the code listed like this:

    <tr>
    <td>
    {$label_array['int_code']}
    </td>
    <td>
    <input type='text' class="f_form" name='int_code' value='$int_cod e'
    size='3' title="Internat ional Code: valid characters 0-9, (3 digits)"/>
    </td>
    </tr>

    So the code in the book is presented in single quotes instead of double
    quotes, but the extra code I have inserted is still in single quotes. I
    know I need to specify maxlength values too. Will the difference in use of
    quotes make much differnce?

    Regards,
    C.B.


  • Oliver Jusinger

    #2
    Re: Parse Errors &amp; Quote Marks

    Cerebral Believer wrote:
    I am having trouble identifying the error here can anyone help?
    Parse error: syntax error on line 318
    $e-mail_1 = $_POST['e-mail_1'];
    "-" isn't allowed in variables, because it's an operator:


    Regards,
    Oliver

    Comment

    • Cerebral Believer

      #3
      Re: Parse Errors &amp; Quote Marks

      I should have pointed out that line 318 is the line displayed, and the error
      is a syntax error, unexpected '='...

      "Cerebral Believer" <nospamthanks@h adenoughalready .comwrote in message
      news:YgSSg.3521 9$TF5.15047@new sfe1-win.ntli.net...
      Hi folks,
      >
      I am having trouble identifying the error here can anyone help?
      >
      Parse error: syntax error on line 318
      >
      $e-mail_1 = $_POST['e-mail_1'];
      >
      Also will my use of " " (double quotes) instead of ' ' (single quotes)
      make much difference to the way this code works? It is from a section of
      code that is returning values to a form after it has been validated.
      >
      <tr>
      <td>
      {$label_array['int_code']}
      </td>
      <td>
      <input type="text" class="f_form" name="int_code" value="$int_cod e"
      size="3" title="Internat ional Code: valid characters 0-9, (3 digits)"/>
      </td>
      </tr>
      >
      I am transfering an HTML form in XHTML 1.0 Transitional to php. The book
      I am reading has the code listed like this:
      >
      <tr>
      <td>
      {$label_array['int_code']}
      </td>
      <td>
      <input type='text' class="f_form" name='int_code' value='$int_cod e'
      size='3' title="Internat ional Code: valid characters 0-9, (3 digits)"/>
      </td>
      </tr>
      >
      So the code in the book is presented in single quotes instead of double
      quotes, but the extra code I have inserted is still in single quotes. I
      know I need to specify maxlength values too. Will the difference in use
      of quotes make much differnce?
      >
      Regards,
      C.B.
      >

      Comment

      • Johnny

        #4
        Re: Parse Errors &amp; Quote Marks


        "Cerebral Believer" <nospamthanks@h adenoughalready .comwrote in message
        news:VATSg.4300 6$SH2.7891@news fe4-gui.ntli.net...
        I should have pointed out that line 318 is the line displayed, and the
        error
        is a syntax error, unexpected '='...
        which is consistent with Oliver's post pointing out that - is not allowed in
        a var name,
        it's interpretting that you said

        $e - mail_1 = $_POST['e-mail_1'];


        php expects operators to be on the right hand side of the =




        Comment

        • Cerebral Believer

          #5
          Re: Parse Errors &amp; Quote Marks


          "Johnny" <removethis.huu anito@hotmail.c omwrote in message
          news:YAUSg.478$ UJ2.294@fed1rea d07...
          >
          "Cerebral Believer" <nospamthanks@h adenoughalready .comwrote in message
          news:VATSg.4300 6$SH2.7891@news fe4-gui.ntli.net...
          >I should have pointed out that line 318 is the line displayed, and the
          error
          >is a syntax error, unexpected '='...
          >
          which is consistent with Oliver's post pointing out that - is not allowed
          in
          a var name,
          it's interpretting that you said
          >
          $e - mail_1 = $_POST['e-mail_1'];
          >
          >
          php expects operators to be on the right hand side of the =
          Yes, thanks I just changed this, and have started to debug - this is my
          first PHP script so I am just getting used to what is allowable in PHP. I
          hadn't seen Johnny's post at the time I posted due to a mess up with my
          newsreader.

          Do you know if:

          if ( $value == "" )
          {
          if ($field != "address_2" or "address_3" or "int_code" or
          "extension" )
          {
          $blank_array[$field] = "blank";
          }
          }

          Is the right way to express that only these fields are allowed to be blank?

          Regards,
          C.B.


          Comment

          • Cerebral Believer

            #6
            Re: Parse Errors &amp; Quote Marks

            Sorry, I meant I hadn't seen Olivers post. Thanks Oliver!

            "Cerebral Believer" <nospamthanks@h adenoughalready .comwrote in message
            news:MMUSg.4684 5$G72.2344@news fe3-gui.ntli.net...
            >
            "Johnny" <removethis.huu anito@hotmail.c omwrote in message
            news:YAUSg.478$ UJ2.294@fed1rea d07...
            >>
            >"Cerebral Believer" <nospamthanks@h adenoughalready .comwrote in message
            >news:VATSg.430 06$SH2.7891@new sfe4-gui.ntli.net...
            >>I should have pointed out that line 318 is the line displayed, and the
            >error
            >>is a syntax error, unexpected '='...
            >>
            >which is consistent with Oliver's post pointing out that - is not allowed
            >in
            >a var name,
            >it's interpretting that you said
            >>
            >$e - mail_1 = $_POST['e-mail_1'];
            >>
            >>
            >php expects operators to be on the right hand side of the =
            >
            Yes, thanks I just changed this, and have started to debug - this is my
            first PHP script so I am just getting used to what is allowable in PHP. I
            hadn't seen Johnny's post at the time I posted due to a mess up with my
            newsreader.
            >
            Do you know if:
            >
            if ( $value == "" )
            {
            if ($field != "address_2" or "address_3" or "int_code" or
            "extension" )
            {
            $blank_array[$field] = "blank";
            }
            }
            >
            Is the right way to express that only these fields are allowed to be
            blank?
            >
            Regards,
            C.B.
            >

            Comment

            • Oliver Jusinger

              #7
              Re: Parse Errors &amp; Quote Marks

              Cerebral Believer wrote:
              Sorry, I meant I hadn't seen Olivers post. Thanks Oliver!
              You're welcome. alt.php isn't available at my provider (yet), maybe that's
              why you didn't get my post.

              if ($field != "address_2" or "address_3" or "int_code" or "extension" )
              I guess you mean

              if (($field != 'address_2') && ($field != 'address_3') ...)

              or better

              if (!in_array($fie ld, array('address_ 2', 'address_3', ...))
              $blank_array[$field] = "blank";
              Is the right way to express that only these fields are allowed to be
              blank?
              Depends on what you do with $blank_array?

              Regards,
              Oliver

              Comment

              Working...