Web browser suddenly not reading PHP?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ricem
    New Member
    • Jan 2009
    • 2

    Web browser suddenly not reading PHP?

    First, let me state I'm a newbie. I'm in the second chapter of "PHP and MySQL Web Development." You build a script in the book, and mine worked just fine yesterday. Now it looks like none of the PHP code is being processed. That script is a little long, so I'll just show my test script to show what's wrong. The top 3 lines are taken from the self-help portion of this website.

    Code:
    <?php
    
      error_reporting(E_ALL);
      ini_set('display_errors', true);
      mysql_query($query, $link_id) or die('<hr />MySQL Error: ' .mysql_error(). '<hr />');  
    
    
     echo '<p>'.'basement'.'</p>';
    
    ?>

    The result is

    MySQL Error: ' .mysql_error(). ''); echo '

    '.'basement'.'
    '; ?>

    with a <hr> below the MySQL line.

    Anybody have a reason it stopped working? I don't think I changed anything, and it was working yesterday.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    there is no database connection made prior to the mysql_query() call. see PHP: MySQL - Manual and PHP: mysql_connect - Manual

    Comment

    • Atli
      Recognized Expert Expert
      • Nov 2006
      • 5062

      #3
      Hi.

      If you do "View Source" in your browser, do you see the entire PHP code?
      If that is so, then your server is indeed processing your PHP code as plain text.

      If it worked yesterday, then something must have changed. Servers don't usually just decide to drop a module for the hell of it :]
      (Unless your using Windows, of course... you never know what that system is up to :P)

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        I could imagine, that (for the rare chance of it) you might have mistaken '' for " somewhere (2 single quotes vs. 1 double quote) which would result in some code actually interpreted as text.

        Comment

        • Atli
          Recognized Expert Expert
          • Nov 2006
          • 5062

          #5
          Yea, that is a remote possibility.
          Although, you would be very *unlucky* if the quotes matched in such a way that it would not produce a syntax error.

          Comment

          • ricem
            New Member
            • Jan 2009
            • 2

            #6
            Okay, it turns out I'm retarded. It wasn't working because I turned retarded overnight and forgot everything I learned. Turns out I was opening the pages in a browser instead of //localhost/. It works okay now. Someone I became unretarded overnight, but I still feel retarded. Sorry to waste your time. And the reason the code looks so weird is I think it went from the < in <?php to the > in hr /> Perhaps next time I will wait a couple days before asking for help to see if I become unretarded first.

            Comment

            • Atli
              Recognized Expert Expert
              • Nov 2006
              • 5062

              #7
              Don't worry about it. We all have spastic moments from time to time.

              It helps to post it tho. Usually makes the problem seem clearer when you try to summarize it in a post.
              And if that doesn't help, we are always happy to point it out for you :]

              Comment

              • edjpereira
                New Member
                • May 2013
                • 1

                #8
                Four years and four months after the last message on this thread, I must say you guys saved me the trouble of removing and reinstalling xampp and going back to the beginning of the book. I had the same issue and, just like ricem, I feel retarded. The echo of the code I created for testing this problem actually said "you, sir, are an idiot". Worthy of a proper Nostradamus...

                Comment

                Working...