zero-perfoliate
zero-perfoliate

Author Topic: "<?php" stopped by ">"  (Read 1124 times)

Offline DaPillow

  • New PHP Members
  • Posts: 4
  • Karma: +0/-0
"<?php" stopped by ">"
« on: December 11, 2009, 05:59:40 PM »
I have my sweet internal php code getting stopped by my greater than sign that I'm echoing. It works fine if the html is brought up using include in my php file, but when going directly to the html I am getting this problem


Here is a picture to show what is happening, the top is how it displays and the lower is what it shows in my page source using Firefox:




Is there some sort of workaround?  Am I just completely oblivious to something extremely obvious?  Probably the latter...

But yeah, thank you in advance,
Alex.

Offline teamatomic

  • PHP Workers
  • **
  • Posts: 17
  • Karma: +0/-0
    • Cool Chef
Re: "<?php" stopped by ">"
« Reply #1 on: December 12, 2009, 06:00:19 AM »
Why dont you cut and paste the code. The graphic you use is not a help.
When in doubt...ski fast
When scared...ski faster
When terrified...point em down

Offline DaPillow

  • New PHP Members
  • Posts: 4
  • Karma: +0/-0
Re: "<?php" stopped by ">"
« Reply #2 on: December 12, 2009, 01:47:29 PM »
Uh, alright...


      <?php
         if($_SESSION['username']){
            echo '<p class="log"> You are logged in as </p><p class="user">'.
            $_SESSION['username']. '</p><p class="log">, Nice.</p>';
         }
         else{
            echo '<form name="input" action="login.php" method="post">
            <p class="input">User ID:</p>
            <input class="textbox" type="text" name="username" />
            <p class="input">Password:</p>
            <input class="textbox" type="password" name="password" />
            <input class="loginimage" type="image" src="Style/Images/login_inactive2.png" alt="Submit Button" />
            </form>';
         }
      ?>

At the start I have <?php session_start(); ?> as well...

And as I said, it works properly if it is gotten using include in a .php file, but when going directly to this, part of an html file, it does not seem to interpret the code correctly.

Offline Afrety

  • PHP Workers
  • **
  • Posts: 6
  • Karma: +0/-0
    • Afrety's Test webside
Re: "<?php" stopped by ">"
« Reply #3 on: December 12, 2009, 02:52:32 PM »
Hi thare.

You will always get an error if $_session["username"] don't exist.
-Try using  isset()
-Other that that, i can't find any errors.

Quote
if(isset($_SESSION['username']))
{
   echo '
   <p class="log"> You are logged in as </p>
   <p class="user">'.$_SESSION['username'].'</p>
   <p class="log">, Nice.</p>';
}
else
{
   echo '
   <form name="input" action="login.php" method="post">
      <p class="input">User ID:</p>
      <input class="textbox" type="text" name="username" />
      <p class="input">Password:</p>
      <input class="textbox" type="password" name="password" />
      <input class="loginimage" type="image" src="Style/Images/login_inactive2.png" alt="Submit Button" />
   </form>';
}

gr
Afrety

Offline DaPillow

  • New PHP Members
  • Posts: 4
  • Karma: +0/-0
Re: "<?php" stopped by ">"
« Reply #4 on: December 12, 2009, 03:56:45 PM »
Alright, well that does help to make things work properly and I appreciate it.

None the less, my php code is still stopped by my greater than sign.  For the record, I am using localhost and not directly going to the file, just to prevent people from saying things such as you should use localhost.

Offline Afrety

  • PHP Workers
  • **
  • Posts: 6
  • Karma: +0/-0
    • Afrety's Test webside
Re: "<?php" stopped by ">"
« Reply #5 on: December 12, 2009, 03:59:51 PM »
Hi

Is it possible you can zip/rar you're site?
Maybe there is an other problem then the script you gave.

gr
Afrety

Offline teamatomic

  • PHP Workers
  • **
  • Posts: 17
  • Karma: +0/-0
    • Cool Chef
Re: "<?php" stopped by ">"
« Reply #6 on: December 12, 2009, 09:28:02 PM »
There is really nothing wrong with the code. The problem most likely is with an extra <?php or ?> or you might have an open html tag somewhere. Look at your log file, it will give a file name and line number. Maybe someplace like this:
C:\Program Files\Apache2.2\logs\error.log


Afrety,
>You will always get an error if $_session["username"] don't exist.

No error, you will just execute the else. if($_session["username"]) is true if the $var has value  or false if it does not exist or is null.


HTH
Teamatomic
When in doubt...ski fast
When scared...ski faster
When terrified...point em down

Offline Afrety

  • PHP Workers
  • **
  • Posts: 6
  • Karma: +0/-0
    • Afrety's Test webside
Re: "<?php" stopped by ">"
« Reply #7 on: December 12, 2009, 10:15:53 PM »
Hi

Some servers shows the error and other not.
So i always see that there are no errors so i can use the script on all servers(if php is updated)
You can use "isset()" or "@".

And for the problem.:
Zip or rar your website and post it (if possible) so i can look in the other files where the problem is.

gr
Afrety

Offline teamatomic

  • PHP Workers
  • **
  • Posts: 17
  • Karma: +0/-0
    • Cool Chef
Re: "<?php" stopped by ">"
« Reply #8 on: December 12, 2009, 10:35:07 PM »
So then,

test.php

<?php
if (!$no_error){echo "what happens";}
?>

Is the above going to cause more than an "undefined" warning?


HTH
Teamatomic

-------------my temp sig--------------------
if($answer == 'yes)
{echo "RTFM";}
else
{echo "Good job";}
------------end temp sig--------------------
When in doubt...ski fast
When scared...ski faster
When terrified...point em down

hotnoob

  • Guest
Re: "<?php" stopped by ">"
« Reply #9 on: December 13, 2009, 12:47:07 PM »
it seems like it's a server configuration error.

do simple php scripts still work on ur server?

also, are u using the .php extension or an extension enabled on ur server to process php?

Offline DaPillow

  • New PHP Members
  • Posts: 4
  • Karma: +0/-0
Re: "<?php" stopped by ">"
« Reply #10 on: December 13, 2009, 03:37:00 PM »
This is my chill site, you have to go to registered.html as it is the one that I was working on this code for.  Realize I have just started learning php, so all of my code is probably horrible looking, as well with my html and css.  It will seem very unorganized, I can assure you of that.

I cleared my error.log then opened the page again, but the most recent thing on it was:
Quote
[Sun Dec 13 17:16:13 2009] [notice] Child 6032: Starting thread to listen on port 8080.
[Sun Dec 13 17:16:13 2009] [notice] Child 6032: Starting thread to listen on port 8080.

And yes, simple php scripts still work on my server.  Even this internal php script in the html file in question works if the page is accessed with an include 'file'; in an external .php file.

Offline Afrety

  • PHP Workers
  • **
  • Posts: 6
  • Karma: +0/-0
    • Afrety's Test webside
Re: "<?php" stopped by ">"
« Reply #11 on: December 14, 2009, 04:57:25 PM »
Hi

Try looking and understanding this script.
Working register, login and logout.

Bugs may accure in style i copy past your css...

Questions pm me.

Greetings
Afrety