first ever PHP site does not have a source...

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

    first ever PHP site does not have a source...

    Hi Gurus

    I am just putting my first PHP site together...

    One thing that I think it strange is that I do not seem to be able to view
    the source. It is almost like the page does not load properly...

    If you like then I can email you the source code, but I thought that this
    may be a problem that occurs frequently...

    TIA

    - Nicolaas


  • circa1979@gmail.com

    #2
    Re: first ever PHP site does not have a source...

    This is because PHP is a server side programming language. You only
    see the output of what PHP processes; not the source itself.

    If I did not understand your question please try to clarify; but I
    think that should answer it for you.

    Comment

    • DJ Craig

      #3
      Re: first ever PHP site does not have a source...

      circa is correct...but thats a confusing way to put it.

      When you view a PHP file in your browser, here is the sequence that
      takes place:
      1. Your browser sends a request to the server for whatever.php
      2. When your server sees that the file you have requested has the file
      extention .php, it interprets (or runs) the program.
      3. The browser sends you the output, or the results of the program; not
      the source code.

      So your browser never even recieves the raw PHP code for the page.
      This is called a server-side language, as opposed to a client-side
      language like Javascript. This is one of the useful things about PHP.
      You can hide things like a large database from the user to prevent them
      from copying the whole thing onto their site; then you just allow them
      access to small parts of it by means of a search box.

      As for the page not loading correctly, there are tons of possibilities;
      me more specific. But it is most likely either a syntax error or an
      endless loop. In any other type of error, the page will still load.
      If it is a syntax error, then it is probably because you left off a
      semi-colon at the end of a line. I've been writing PHP forever and I
      still do that sometimes. On most servers, for some reason, if there is
      a syntax error on the page, it simply returns to the browser
      "<html><hea d></head><body></body></html>" so if you see that in the
      view source, that tells you it's a syntax error.
      If it's an endless loop, which is less likely, the page won't load at
      all; it will just sit there saying "Contacting whatever.com" in the
      status bar until it times out. Or some servers will time out after 30
      seconds and send a message back to the browser giving a description of
      the problem.
      An endless loop is caused by some type of repitition structure (either
      while, for, foreach, or do while) that never ends. For example, this
      would cause an endless loop:
      <?php
      $flag = 1;
      while($flag = 1)
      {
      echo 'hello world<br />';
      }
      ?>

      Comment

      • WindAndWaves

        #4
        Re: first ever PHP site does not have a source...


        <circa1979@gmai l.com> wrote in message
        news:1105661597 .477439.182120@ z14g2000cwz.goo glegroups.com.. .[color=blue]
        > This is because PHP is a server side programming language. You only
        > see the output of what PHP processes; not the source itself.
        >
        > If I did not understand your question please try to clarify; but I
        > think that should answer it for you.
        >[/color]

        Sorry, what I actually meant was that if I right mouse-click to see the
        source or if I go to edit - view source, this function is unavailable. It
        is even that bad that if I go save as ... and try to save the file locally
        as a text file then it tells me that the file is unavailable....

        I hope my problem seems a little less silly now.

        Thank you for taking the time to answer.
        - Nicolaas


        Comment

        • WindAndWaves

          #5
          Re: first ever PHP site does not have a source...


          "DJ Craig" <spit@djtriciti es.com> wrote in message
          news:1105665240 .234091.87020@c 13g2000cwb.goog legroups.com...[color=blue]
          > circa is correct...but thats a confusing way to put it.
          >
          > When you view a PHP file in your browser, here is the sequence that
          > takes place:
          > 1. Your browser sends a request to the server for whatever.php
          > 2. When your server sees that the file you have requested has the file
          > extention .php, it interprets (or runs) the program.
          > 3. The browser sends you the output, or the results of the program; not
          > the source code.
          >
          > So your browser never even recieves the raw PHP code for the page.
          > This is called a server-side language, as opposed to a client-side
          > language like Javascript. This is one of the useful things about PHP.
          > You can hide things like a large database from the user to prevent them
          > from copying the whole thing onto their site; then you just allow them
          > access to small parts of it by means of a search box.
          >
          > As for the page not loading correctly, there are tons of possibilities;
          > me more specific. But it is most likely either a syntax error or an
          > endless loop. In any other type of error, the page will still load.
          > If it is a syntax error, then it is probably because you left off a
          > semi-colon at the end of a line. I've been writing PHP forever and I
          > still do that sometimes. On most servers, for some reason, if there is
          > a syntax error on the page, it simply returns to the browser
          > "<html><hea d></head><body></body></html>" so if you see that in the
          > view source, that tells you it's a syntax error.
          > If it's an endless loop, which is less likely, the page won't load at
          > all; it will just sit there saying "Contacting whatever.com" in the
          > status bar until it times out. Or some servers will time out after 30
          > seconds and send a message back to the browser giving a description of
          > the problem.
          > An endless loop is caused by some type of repitition structure (either
          > while, for, foreach, or do while) that never ends. For example, this
          > would cause an endless loop:
          > <?php
          > $flag = 1;
          > while($flag = 1)
          > {
          > echo 'hello world<br />';
          > }
          > ?>
          >[/color]

          Hi Craig

          Thank you for your in-depth description.

          I am afraid that it is none of the above, as the page loads perfectly.

          Unfortunately, I can not post you the url at the moment, because I would
          have to check with my client first. Would you like me to send you the file
          PHP or post it on here? If so, how do I do that, if I post it to the
          newsgroup. Can I attach it or just copy and paste below?



          Comment

          • Virgil Green

            #6
            Re: first ever PHP site does not have a source...

            "WindAndWav es" <access@ngaru.c om> wrote in message
            news:PCGFd.7802 $mo2.545710@new s.xtra.co.nz...[color=blue]
            >
            > <circa1979@gmai l.com> wrote in message
            > news:1105661597 .477439.182120@ z14g2000cwz.goo glegroups.com.. .[color=green]
            > > This is because PHP is a server side programming language. You only
            > > see the output of what PHP processes; not the source itself.
            > >
            > > If I did not understand your question please try to clarify; but I
            > > think that should answer it for you.
            > >[/color]
            >
            > Sorry, what I actually meant was that if I right mouse-click to see the
            > source or if I go to edit - view source, this function is unavailable. It
            > is even that bad that if I go save as ... and try to save the file locally
            > as a text file then it tells me that the file is unavailable....
            >
            > I hope my problem seems a little less silly now.[/color]

            It sounds like there may be some javascript on that page disabling the
            options for viewing/saving the source.

            --
            Virgil


            Comment

            • DJ Craig

              #7
              Re: first ever PHP site does not have a source...

              Thats really weird. Have you tried it in different browsers? Try
              disabling java and javascript in the preferences and see if that makes
              any difference. if you have a DOM inspector try running that on it and
              see what it says. If you don't have one download Firefox (a great
              browser!) at http://www.firefox.com then install the web developer
              extention (Tools -> Extentions -> Get More Extentions) btw does anyone
              know of any stand-alone DOM inspector applications? My fingers are too
              tired to explain what a DOM inspector is :) but its pretty simple just
              mess with it some.
              Have you tried it in different browsers? Try disabling java and
              javascript in the preferences and see if that makes any difference.
              If you want a good browser for testing sites on, again, download
              firefox and the web developer extention.
              If this doesn't help, just copy and paste the source code into here.

              Comment

              • WindAndWaves

                #8
                Re: first ever PHP site does not have a source...


                "DJ Craig" <spit@djtriciti es.com> wrote in message
                news:1105785199 .933379.273060@ z14g2000cwz.goo glegroups.com.. .[color=blue]
                > Thats really weird. Have you tried it in different browsers? Try
                > disabling java and javascript in the preferences and see if that makes
                > any difference. if you have a DOM inspector try running that on it and
                > see what it says. If you don't have one download Firefox (a great
                > browser!) at http://www.firefox.com then install the web developer
                > extention (Tools -> Extentions -> Get More Extentions) btw does anyone
                > know of any stand-alone DOM inspector applications? My fingers are too
                > tired to explain what a DOM inspector is :) but its pretty simple just
                > mess with it some.
                > Have you tried it in different browsers? Try disabling java and
                > javascript in the preferences and see if that makes any difference.
                > If you want a good browser for testing sites on, again, download
                > firefox and the web developer extention.
                > If this doesn't help, just copy and paste the source code into here.
                >[/color]

                Hi Dj

                I think I know what it was, and yes I do have firefox. I think the little
                line in my stylesheet

                BODY {background: URL()}

                may have been in the way, or something like that, anyway, I will do some
                more research, because it could still be the php....

                Javascript has little to do with it I think, even though I have several of
                the scripts running, as the error only occurs on the server and it never
                used to when the pages were still *.html

                Thanks for your comments

                - Nicolaas


                Comment

                Working...