Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    New Coder
    Join Date
    Sep 2009
    Posts
    50
    Thanks
    1
    Thanked 0 Times in 0 Posts

    -> Mistakenly regarded as php end tag ?>

    I composed my php codes through Microsoft Notepad. I use <?php and ?> as start and end tags. They were working well with another free web hosting service. Now I moved to another hosting service and found a problem:

    The server mistakenly treat first -> as ?> and end the problem. For example my code is:

    Code:
    <?php
      require_once("user.php");
      if (0!=strlen(trim($_POST["hiddenUserId"])) && "null"!=$_POST["hiddenUserId"]) 
      { $u = User::getById($_POST["hiddenUserId"]);
        $u->col1stWidth = $_POST["width1st"];
        $u->recentNumber = $_POST["numberCol"];
        $u->save();
      }
    ?>
    It stops at first -> just before col1stWidth. I actually tried other php files, all having same problem.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    And why do you believe that its treating that as an ?>? Does it show the remaining code as plain text in the output?
    Enable you're error reporting or view you're error logs. Chances are you have an issue with regards to a fatal error on accessing an invalid member on a non-object. So you script terminates not because its confused by the end, rather because you have a fatal error. Cause could be due to invalid definitions, failed inlcludes (not in this case since its required and would have died there) and invalid arguments for constructions, or invalid namespace definitions (5.3+).
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Should User not be $User? (Mind's in slow mode today ).

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    No, User represents a static call to the User class. $u is the resulting variable; I assumed that the User::getbyid method returned a new User instance.

    Edit:
    ALSO, just thought of another potential problem here that could be cause and reason. If the remaining (or at least some of it) code shows as plain text in you're browser, open you're source code to see if the previous is embedded as an html tag. If so, you're current configurations are not allowing PHP to be parsed as php, rather they are parsed as .html instead. I also assumed that this file is a .php one since no shebang line is present to indicate otherwise.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #5
    New Coder
    Join Date
    Sep 2009
    Posts
    50
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I would not think it is a fatal error because it runs well in another web hosting service. And yes, the remaining code as plain text in the output. However, your guess is reasonable because at least my db.php had been changed. If I have connection problem, do you think it would show this kind of error rather than connection error message? Thanks.

    Quote Originally Posted by Fou-Lu View Post
    And why do you believe that its treating that as an ?>? Does it show the remaining code as plain text in the output?
    Enable you're error reporting or view you're error logs. Chances are you have an issue with regards to a fatal error on accessing an invalid member on a non-object. So you script terminates not because its confused by the end, rather because you have a fatal error. Cause could be due to invalid definitions, failed inlcludes (not in this case since its required and would have died there) and invalid arguments for constructions, or invalid namespace definitions (5.3+).

  • #6
    New Coder
    Join Date
    Sep 2009
    Posts
    50
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Yes, most likely this is the case. It is .php file.

    Quote Originally Posted by Fou-Lu View Post
    ALSO, just thought of another potential problem here that could be cause and reason. If the remaining (or at least some of it) code shows as plain text in you're browser, open you're source code to see if the previous is embedded as an html tag. If so, you're current configurations are not allowing PHP to be parsed as php, rather they are parsed as .html instead. I also assumed that this file is a .php one since no shebang line is present to indicate otherwise.

  • #7
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Look at my edit in the last post I made. Check that source, does that show as an html tag that contains that code?

    Edit:
    Ah great, you saw that last edit.
    Confirm PHP is runnable:
    PHP Code:
    // Save as phpinfo.php
    <?php
    phpinfo
    ();
    ?>
    Does that list all of the configuration information about php, or does that show the text:
    Code:
    <?php
    phpinfo();
    ?>
    ?
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #8
    New Coder
    Join Date
    Sep 2009
    Posts
    50
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Show me nothing. Complete blank with Done in footnote.

    Quote Originally Posted by Fou-Lu View Post
    Look at my edit in the last post I made. Check that source, does that show as an html tag that contains that code?

    Edit:
    Ah great, you saw that last edit.
    Confirm PHP is runnable:
    PHP Code:
    // Save as phpinfo.php
    <?php
    phpinfo
    ();
    ?>
    Does that list all of the configuration information about php, or does that show the text:
    Code:
    <?php
    phpinfo();
    ?>
    ?

  • #9
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Quote Originally Posted by Fou-Lu View Post
    No, User represents a static call to the User class. $u is the resulting variable; I assumed that the User::getbyid method returned a new User instance.
    I thought I was missing something. I'm having a codeblind mode day.

  • #10
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    If you check you're source code, I'll bet it shows that as an HTML tag.
    Problem here, .php is not set up to parse php files. If this is a personal server, you'll need to add:
    Code:
    LoadModule php5_module "/path/to/php5apache2_2.dll" #use php5apache2.dll for apache 2.x, use php5apache.dll for apache1.x
    AddType application/x-httpd-php .php
    That should do it. If you're hosted, contact you're host and tell them to enable you're php. If you're on a free host, chances are you don't have php available for use.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    registereduser4 (03-25-2010)

  • #11
    New Coder
    Join Date
    Sep 2009
    Posts
    50
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thank you so much for such quick to identify the problem.

    Quote Originally Posted by Fou-Lu View Post
    If you check you're source code, I'll bet it shows that as an HTML tag.
    Problem here, .php is not set up to parse php files. If this is a personal server, you'll need to add:
    Code:
    LoadModule php5_module "/path/to/php5apache2_2.dll" #use php5apache2.dll for apache 2.x, use php5apache.dll for apache1.x
    AddType application/x-httpd-php .php
    That should do it. If you're hosted, contact you're host and tell them to enable you're php. If you're on a free host, chances are you don't have php available for use.

  • #12
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Quote Originally Posted by registereduser4 View Post
    Thank you so much for such quick to identify the problem.
    Hah, I just noticed I didn't tell you where to add that. It needs to go into httpd.conf, generally located (on windows) at C:\Program Files\apache\conf or in Linux at /etc/httpd/conf
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •