problem with simple php code

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

    #1

    problem with simple php code

    I'm just learning php, and one of the first things in the book I'm
    reading has me make this file-
    <html>
    <head>
    <title>PHP Test</title>
    </head>
    <body>
    <p>This is an HTML line
    <p>
    <?php
    echo "This is a PHP line";
    Phpinfo();
    ?>
    </body>
    </html>

    I typed in in Notepad, saved it as test.php, ftp it to my ISP, then
    viewed in a browser and got the following error-
    Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in
    /home/fearofdo/public_html/test2.php on line 9

    I asked my ISP if php/mysql was installed and turned on and configured
    correctly, they said yes and that my code was wrong, that it had <93>
    and <94where there should have been quotes, so they changed it and
    now it works, creating the proper display.

    This is all very odd to me...when I look at the original file that my
    ISP said they corrected, there are now double quotes around the line
    This is a PHP line. I created a new file from scratch, made sure it had
    quotes, uploaded it and what do you know, I get the error message
    again. When I view the file/code from my FTP client, it shows the
    quotes, absolutely the correct code, so why is it not working?

    I guess my question is, what the heck is happening? I'm not even sure
    where to begin...how and why is the code getting changed, and if it is
    getting changed, why does it not look to me like it has changed, and
    why the <93>...where does that come from? How do I prevent this?

  • kday33@gmail.com

    #2
    Re: problem with simple php code

    I don't know anything about <93or <94tags, but the code you posted
    works fine on my setup.

    You mentioned that you saved it as "test.php", but then said the error
    occured at "/home/fearofdo/public_html/test2.php". Are you sure you
    are looking at only one file? test.php vs. test2.php?

    Comment

    • Brent Palmer

      #3
      Re: problem with simple php code


      <alice@fearofdo lls.comwrote in message
      news:1164155861 .660629.38100@m 7g2000cwm.googl egroups.com...
      I'm just learning php, and one of the first things in the book I'm
      reading has me make this file-
      <html>
      <head>
      <title>PHP Test</title>
      </head>
      <body>
      <p>This is an HTML line
      <p>
      <?php
      echo "This is a PHP line";
      Phpinfo();
      ?>
      </body>
      </html>
      >
      I typed in in Notepad, saved it as test.php, ftp it to my ISP, then
      viewed in a browser and got the following error-
      Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in
      /home/fearofdo/public_html/test2.php on line 9
      >
      I asked my ISP if php/mysql was installed and turned on and configured
      correctly, they said yes and that my code was wrong, that it had <93>
      and <94where there should have been quotes, so they changed it and
      now it works, creating the proper display.
      >
      This is all very odd to me...when I look at the original file that my
      ISP said they corrected, there are now double quotes around the line
      This is a PHP line. I created a new file from scratch, made sure it had
      quotes, uploaded it and what do you know, I get the error message
      again. When I view the file/code from my FTP client, it shows the
      quotes, absolutely the correct code, so why is it not working?
      >
      I guess my question is, what the heck is happening? I'm not even sure
      where to begin...how and why is the code getting changed, and if it is
      getting changed, why does it not look to me like it has changed, and
      why the <93>...where does that come from? How do I prevent this?
      >
      The only thing springs to mind is, what transfer mode are you using with
      your FTP software. Are you using auto, binary or ASCII.
      Your script works fine this end.
      Regards,

      Brent Palmer.


      Comment

      • Paul Herber

        #4
        Re: problem with simple php code

        On 21 Nov 2006 16:37:41 -0800, alice@fearofdol ls.com wrote:
        >I'm just learning php, and one of the first things in the book I'm
        >reading has me make this file-
        ><html>
        ><head>
        ><title>PHP Test</title>
        ></head>
        ><body>
        ><p>This is an HTML line
        ><p>
        ><?php
        echo "This is a PHP line";
        Phpinfo();
        >?>
        ></body>
        ></html>
        >
        >I typed in in Notepad, saved it as test.php, ftp it to my ISP, then
        >viewed in a browser and got the following error-
        >Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in
        >/home/fearofdo/public_html/test2.php on line 9
        >
        >I asked my ISP if php/mysql was installed and turned on and configured
        >correctly, they said yes and that my code was wrong, that it had <93>
        >and <94where there should have been quotes, so they changed it and
        >now it works, creating the proper display.
        Don't know how this is happening in Notepad but it looks to me like it
        could be smart quotes characters 91 and 92 instead of a single quote.

        Characters (decimal) 93 and 94 are ] and ^


        --
        Regards, Paul Herber, Sandrila Ltd. http://www.pherber.com/
        Diacrit accented characters http://www.diacrit.sandrila.co.uk/
        Email address in headers is invalid.

        Comment

        • alice@fearofdolls.com

          #5
          Re: problem with simple php code

          kday33@gmail.co m wrote:
          I don't know anything about <93or <94tags, but the code you posted
          works fine on my setup.
          >
          You mentioned that you saved it as "test.php", but then said the error
          occured at "/home/fearofdo/public_html/test2.php". Are you sure you
          are looking at only one file? test.php vs. test2.php?
          Yes, test2 was the second one I created, a duplicate of the first just
          so I could see the error again. It created that error, yet when I view
          it, it looks fine, it should work.

          Comment

          • alice@fearofdolls.com

            #6
            Re: problem with simple php code

            >
            The only thing springs to mind is, what transfer mode are you using with
            your FTP software. Are you using auto, binary or ASCII.
            It's in binary mode.

            Comment

            • Jerry Stuckle

              #7
              Re: problem with simple php code

              alice@fearofdol ls.com wrote:
              >>The only thing springs to mind is, what transfer mode are you using with
              >>your FTP software. Are you using auto, binary or ASCII.
              >
              >
              It's in binary mode.
              >
              Are you really using MS Notepad, or are you using something else? x'93'
              and x'94' are the left and right quote symbols in some other programs
              like Wordpad, but I haven't seen Notepad save them that way.

              Also, you're transferring ascii data, so you should be using ascii
              transfer mode. But that won't cause this problem.

              --
              =============== ===
              Remove the "x" from my email address
              Jerry Stuckle
              JDS Computer Training Corp.
              jstucklex@attgl obal.net
              =============== ===

              Comment

              • alice@fearofdolls.com

                #8
                Re: problem with simple php code

                >
                Are you really using MS Notepad, or are you using something else? x'93'
                and x'94' are the left and right quote symbols in some other programs
                like Wordpad, but I haven't seen Notepad save them that way.
                >
                That must be the problem, but I am using notepad. What else can I use
                that would not change it?
                Also, you're transferring ascii data, so you should be using ascii
                transfer mode. But that won't cause this problem.
                >
                That is true I guess...I haven't changed that setting in FTP for years,
                and I've transfered all kinds of files without any problems before.
                --
                =============== ===
                Remove the "x" from my email address
                Jerry Stuckle
                JDS Computer Training Corp.
                jstucklex@attgl obal.net
                =============== ===

                Comment

                • Dave Pyles

                  #9
                  Re: problem with simple php code

                  On 11/21/2006 7:37 PM, alice@fearofdol ls.com wrote:
                  I'm just learning php, and one of the first things in the book I'm
                  reading has me make this file-
                  <html>
                  <head>
                  <title>PHP Test</title>
                  </head>
                  <body>
                  <p>This is an HTML line
                  <p>
                  <?php
                  echo "This is a PHP line";
                  Phpinfo();
                  ?>
                  </body>
                  </html>
                  >
                  I typed in in Notepad, saved it as test.php, ftp it to my ISP, then
                  viewed in a browser and got the following error-
                  Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in
                  /home/fearofdo/public_html/test2.php on line 9
                  >
                  I asked my ISP if php/mysql was installed and turned on and configured
                  correctly, they said yes and that my code was wrong, that it had <93>
                  and <94where there should have been quotes, so they changed it and
                  now it works, creating the proper display.
                  >
                  This is all very odd to me...when I look at the original file that my
                  ISP said they corrected, there are now double quotes around the line
                  This is a PHP line. I created a new file from scratch, made sure it had
                  quotes, uploaded it and what do you know, I get the error message
                  again. When I view the file/code from my FTP client, it shows the
                  quotes, absolutely the correct code, so why is it not working?
                  >
                  I guess my question is, what the heck is happening? I'm not even sure
                  where to begin...how and why is the code getting changed, and if it is
                  getting changed, why does it not look to me like it has changed, and
                  why the <93>...where does that come from? How do I prevent this?
                  >
                  Try writing your file like this:

                  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
                  <html xmlns="http://www.w3.org/1999/xhtml">
                  <head>
                  <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
                  <title>First PHP Script</title>
                  </head>
                  <body>
                  <?php
                  phpinfo();
                  ?>
                  </body>
                  </html>

                  That should return the PHP Info page.

                  Dave Pyles

                  Comment

                  • alice@fearofdolls.com

                    #10
                    Re: problem with simple php code


                    alice@fearofdol ls.com wrote:
                    >
                    Are you really using MS Notepad, or are you using something else? x'93'
                    and x'94' are the left and right quote symbols in some other programs
                    like Wordpad, but I haven't seen Notepad save them that way.
                    >
                    That must be the problem, but I am using notepad. What else can I use
                    that would not change it?
                    >
                    Also, you're transferring ascii data, so you should be using ascii
                    transfer mode. But that won't cause this problem.
                    >
                    Well transfering it in ASCII didn't help.

                    Comment

                    • alice@fearofdolls.com

                      #11
                      Re: problem with simple php code


                      Dave Pyles wrote:
                      On 11/21/2006 7:37 PM, alice@fearofdol ls.com wrote:
                      I'm just learning php, and one of the first things in the book I'm
                      reading has me make this file-
                      <html>
                      <head>
                      <title>PHP Test</title>
                      </head>
                      <body>
                      <p>This is an HTML line
                      <p>
                      <?php
                      echo "This is a PHP line";
                      Phpinfo();
                      ?>
                      </body>
                      </html>

                      I typed in in Notepad, saved it as test.php, ftp it to my ISP, then
                      viewed in a browser and got the following error-
                      Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in
                      /home/fearofdo/public_html/test2.php on line 9

                      I asked my ISP if php/mysql was installed and turned on and configured
                      correctly, they said yes and that my code was wrong, that it had <93>
                      and <94where there should have been quotes, so they changed it and
                      now it works, creating the proper display.

                      This is all very odd to me...when I look at the original file that my
                      ISP said they corrected, there are now double quotes around the line
                      This is a PHP line. I created a new file from scratch, made sure it had
                      quotes, uploaded it and what do you know, I get the error message
                      again. When I view the file/code from my FTP client, it shows the
                      quotes, absolutely the correct code, so why is it not working?

                      I guess my question is, what the heck is happening? I'm not even sure
                      where to begin...how and why is the code getting changed, and if it is
                      getting changed, why does it not look to me like it has changed, and
                      why the <93>...where does that come from? How do I prevent this?
                      Try writing your file like this:
                      >
                      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
                      <html xmlns="http://www.w3.org/1999/xhtml">
                      <head>
                      <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
                      <title>First PHP Script</title>
                      </head>
                      <body>
                      <?php
                      phpinfo();
                      ?>
                      </body>
                      </html>
                      >
                      That should return the PHP Info page.
                      >
                      I could do that, but that's not really the issue, the issue is, why is
                      what I'm doing not working in the first place, according to the book it
                      should work, and if it's not I don't really know how to proceed. This
                      is very discouraging for someone just trying to learn how to use PHP
                      and other web technology.
                      Dave Pyles

                      Comment

                      • Jerry Stuckle

                        #12
                        Re: problem with simple php code

                        alice@fearofdol ls.com wrote:
                        alice@fearofdol ls.com wrote:
                        >
                        >>>Are you really using MS Notepad, or are you using something else? x'93'
                        >>>and x'94' are the left and right quote symbols in some other programs
                        >>>like Wordpad, but I haven't seen Notepad save them that way.
                        >>>
                        >>
                        >>That must be the problem, but I am using notepad. What else can I use
                        >>that would not change it?
                        >>
                        >>
                        >>>Also, you're transferring ascii data, so you should be using ascii
                        >>>transfer mode. But that won't cause this problem.
                        >>>
                        >>
                        >
                        Well transfering it in ASCII didn't help.
                        >
                        No, ASCII just affects the newline characters. But if you're uploading
                        the a Unix system you'll see them each line has an extra ^M in a Unix
                        editor such as vim.

                        I've tried it here on W2K and W2K3 Server, and I haven't been able to
                        duplicate it. But I find it easy to do in word processors.

                        It's a very interesting problem. Wish I had an answer for you.

                        --
                        =============== ===
                        Remove the "x" from my email address
                        Jerry Stuckle
                        JDS Computer Training Corp.
                        jstucklex@attgl obal.net
                        =============== ===

                        Comment

                        • alice@fearofdolls.com

                          #13
                          Re: problem with simple php code

                          Maybe I'll try it in Word.

                          Jerry Stuckle wrote:
                          alice@fearofdol ls.com wrote:
                          alice@fearofdol ls.com wrote:
                          >>Are you really using MS Notepad, or are you using something else? x'93'
                          >>and x'94' are the left and right quote symbols in some other programs
                          >>like Wordpad, but I haven't seen Notepad save them that way.
                          >>
                          >
                          >That must be the problem, but I am using notepad. What else can I use
                          >that would not change it?
                          >
                          >
                          >>Also, you're transferring ascii data, so you should be using ascii
                          >>transfer mode. But that won't cause this problem.
                          >>
                          >
                          Well transfering it in ASCII didn't help.
                          >
                          No, ASCII just affects the newline characters. But if you're uploading
                          the a Unix system you'll see them each line has an extra ^M in a Unix
                          editor such as vim.
                          >
                          I've tried it here on W2K and W2K3 Server, and I haven't been able to
                          duplicate it. But I find it easy to do in word processors.
                          >
                          It's a very interesting problem. Wish I had an answer for you.
                          >
                          --
                          =============== ===
                          Remove the "x" from my email address
                          Jerry Stuckle
                          JDS Computer Training Corp.
                          jstucklex@attgl obal.net
                          =============== ===

                          Comment

                          • Jerry Stuckle

                            #14
                            Re: problem with simple php code

                            alice@fearofdol ls.com wrote:
                            Jerry Stuckle wrote:
                            >
                            >>alice@fearofd olls.com wrote:
                            >>
                            >>>alice@fearof dolls.com wrote:
                            >>>
                            >>>
                            >>>>>Are you really using MS Notepad, or are you using something else? x'93'
                            >>>>>and x'94' are the left and right quote symbols in some other programs
                            >>>>>like Wordpad, but I haven't seen Notepad save them that way.
                            >>>>>
                            >>>>
                            >>>>That must be the problem, but I am using notepad. What else can I use
                            >>>>that would not change it?
                            >>>>
                            >>>>
                            >>>>
                            >>>>>Also, you're transferring ascii data, so you should be using ascii
                            >>>>>transfer mode. But that won't cause this problem.
                            >>>>>
                            >>>>
                            >>>Well transfering it in ASCII didn't help.
                            >>>
                            >>
                            >>No, ASCII just affects the newline characters. But if you're uploading
                            >>the a Unix system you'll see them each line has an extra ^M in a Unix
                            >>editor such as vim.
                            >>
                            >>I've tried it here on W2K and W2K3 Server, and I haven't been able to
                            >>duplicate it. But I find it easy to do in word processors.
                            >>
                            >>It's a very interesting problem. Wish I had an answer for you.
                            >>
                            >>--
                            >>============= =====
                            >>Remove the "x" from my email address
                            >>Jerry Stuckle
                            >>JDS Computer Training Corp.
                            >>jstucklex@att global.net
                            >>============= =====
                            >
                            >
                            Maybe I'll try it in Word.
                            >
                            (Top posting fixed)

                            Word is definitely the WRONG way to go. You need an ASCII text editor,
                            not a word processor.

                            In fact, WORD will give you exactly the problem you're seeing, even if
                            you save it in text format. Even the x'93' and x'94" characters.

                            --
                            =============== ===
                            Remove the "x" from my email address
                            Jerry Stuckle
                            JDS Computer Training Corp.
                            jstucklex@attgl obal.net
                            =============== ===

                            Comment

                            • alice@fearofdolls.com

                              #15
                              Re: problem with simple php code


                              Jerry Stuckle wrote:
                              alice@fearofdol ls.com wrote:
                              alice@fearofdol ls.com wrote:
                              >>Are you really using MS Notepad, or are you using something else? x'93'
                              >>and x'94' are the left and right quote symbols in some other programs
                              >>like Wordpad, but I haven't seen Notepad save them that way.
                              >>
                              >
                              >That must be the problem, but I am using notepad. What else can I use
                              >that would not change it?
                              >
                              >
                              >>Also, you're transferring ascii data, so you should be using ascii
                              >>transfer mode. But that won't cause this problem.
                              >>
                              >
                              Well transfering it in ASCII didn't help.
                              >
                              No, ASCII just affects the newline characters. But if you're uploading
                              the a Unix system you'll see them each line has an extra ^M in a Unix
                              editor such as vim.
                              >
                              I've tried it here on W2K and W2K3 Server, and I haven't been able to
                              duplicate it. But I find it easy to do in word processors.
                              >
                              Well here's another problem...if I create it in word, I can't save it
                              as a .php file. I could save it as .txt then change it, but won't that
                              mess it up?
                              It's a very interesting problem. Wish I had an answer for you.
                              >
                              --
                              =============== ===
                              Remove the "x" from my email address
                              Jerry Stuckle
                              JDS Computer Training Corp.
                              jstucklex@attgl obal.net
                              =============== ===

                              Comment

                              Working...