1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need help with PHP5

Discussion in 'Web and Network Services' started by GhettoBSD, Mar 16, 2010.

  1. GhettoBSD

    GhettoBSD New Member

    Messages:
    38
    Thanks Received:
    2
    I'm moving a site from a linux host to a bsd host. Everything is working out except for php!

    The page in question worked fine on linux php5.2.8, and bsd php5-5.2.11. But the difference in version has caused some code to not work properly.

    The code in question is this:

    Code:
    $link_pt1 = '<li';
    $link_pt2 = '><a href="';
    $link_pt3 = '">';
    $link_pt4 = '></a></li>';


    While on linux host it works great, on bsd it displays:
    Code:
    '; $link_pt4 = '>'; $link_01 = home; $link_02 = services; $link_03 = about; $link_04 = contact; $link_05 = espa


    Everything else is working fine (as far as php is concerned). Any ideas?

    PS Sorry DD! ]:p
     
  2. jailed

    jailed Member

    Messages:
    147
    Thanks Received:
    14
    Code:
    ';
    $link_pt4 = '>';
    $link_01 = home;
    $link_02 = services;
    $link_03 = about;
    $link_04 = contact;
    $link_05 = espa 


    First, home, services, about and contact are constants in your example.

    Constants are used as this:
    Code:
    define("home", "Home);
    echo home;


    For strings you must write as,
    Code:
    $link = "home";


    Then, if I'm not wrong, you say that on BSD server server responses the code. If you mean apache, then you must install php module.

    What happens when you write php -f file.php on your console?
     
    GhettoBSD thanks for this.
  3. SirDice

    SirDice Moderator Staff Member Moderator

    Messages:
    17,610
    Thanks Received:
    2,381
    Did you install PHP5 using a package? If so, the package doesn't contain the apache module. You need to build php5 from the port.
     
    GhettoBSD thanks for this.
  4. GhettoBSD

    GhettoBSD New Member

    Messages:
    38
    Thanks Received:
    2
    Thanks for the replies!

    Jailed: interesting, php -f header.php returns this:
    Code:
    PHP Notice:  Use of undefined constant home - assumed 'home' in /usr/local/www/apache22/website/header.php on line 33
    PHP Notice:  Use of undefined constant services - assumed 'services' in /usr/local/www/apache22/website/header.php on line 34
    PHP Notice:  Use of undefined constant about - assumed 'about' in /usr/local/www/apache22/website/header.php on line 35
    PHP Notice:  Use of undefined constant contact - assumed 'contact' in /usr/local/www/apache22/website/header.php on line 36
    PHP Notice:  Use of undefined constant espanol - assumed 'espanol' in /usr/local/www/apache22/website/header.php on line 37
    PHP Notice:  Use of undefined constant Home - assumed 'Home' in /usr/local/www/apache22/website/header.php on line 47
    PHP Notice:  Use of undefined constant Services - assumed 'Services' in /usr/local/www/apache22/website/header.php on line 48
    PHP Notice:  Use of undefined constant Forum - assumed 'Forum' in /usr/local/www/apache22/website/header.php on line 52
    PHP Notice:  Use of undefined constant Blog - assumed 'Blog' in /usr/local/www/apache22/website/header.php on line 53
    <li><a href="Home.php">Home</a></li>PHP Notice:  Use of undefined constant services - assumed 'services' in /usr/local/www/apache22/website/header.php on line 63
    


    So it turns out there is more than 1 error! hahaha oops :p

    Someone else pointed how nasty the code is and about constants. So I will look into cleaning it up in the future.


    SirDice: Well I should have probably posted my stats haha

    I started off with:

    Code:
    FreeBSD 8 RELEASE
    wordpress: 2.9.2
    php5-5.2.11 PHP Scripting Language
    php5-mysql-5.2.11 The mysql shared extension for php
    mysql-client-5.0.86 Multithreaded SQL database (client)
    mysql-server-5.0.86 Multithreaded SQL database (server)
    apache-2.2.13 Version 2.2.x of Apache web server with prefork MPM.


    And ended up with
    Code:
    FreeBSD 8 release
    mysql-client-5.1.39 Multithreaded SQL database (client)
    mysql-server-5.1.39 Multithreaded SQL database (server)
    php5-5.2.11 PHP Scripting Language
    php5-extensions-1.3 A "meta-port" to install PHP extensions
    php5-mysql-5.2.11 The mysql shared extension for php
    apache-2.2.13 Version 2.2.x of Apache web server with prefork MPM.
    


    I also installed all through ports.


    The reason it wasn't displaying properly was the difference in php versions. The older version didn't have a problem processing this:

    Code:
    <? menu();?>


    But the newer version did. So I modified it to this:
    Code:
    <?php menu(); ?>

    and it works!

    Thanks for your time guys!

    Oh and BTW, this was to get wordpress up and running hahaha :p But I will look into geeklog as recommended by my buddy!
     
  5. roddierod

    roddierod Member

    Messages:
    705
    Thanks Received:
    80
    That not a version problem, that because you had short tags enabled on the Linux machine and not the BSD machine.
     
    GhettoBSD thanks for this.
  6. GhettoBSD

    GhettoBSD New Member

    Messages:
    38
    Thanks Received:
    2
    Hmm, so how can I enable short tags on BSD?

    Thanks!
     
  7. DutchDaemon

    DutchDaemon Administrator Staff Member Administrator Moderator

    Messages:
    10,765
    Thanks Received:
    1,870
    /usr/local/etc/php.ini

    Code:
    ; Allow the <? tag.  Otherwise, only <?php and <script> tags are recognized.  
    ; NOTE: Using short tags should be avoided when developing applications or
    ; libraries that are meant for redistribution, or deployment on PHP
    ; servers which are not under your control, because short tags may not
    ; be supported on the target server. For portable, redistributable code,
    ; be sure not to use short tags.
    short_open_tag = On
    
     
    GhettoBSD thanks for this.
  8. GhettoBSD

    GhettoBSD New Member

    Messages:
    38
    Thanks Received:
    2
    you the man, thanks!