Need help with PHP5

Discussion related to network/web services such as Apache, BIND Sendmail, etc.

Need help with PHP5

Postby GhettoBSD » 16 Mar 2010, 02:58

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: Select all
$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: Select all
'; $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
You can never say never and never say always.
Check out the new GhettoBSD.org site. Now with Web 3.0!
GhettoBSD
Junior Member
 
Posts: 38
Joined: 27 Jul 2009, 16:31

Postby jailed » 16 Mar 2010, 06:22

Code: Select all
';
$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: Select all
define("home", "Home);
echo home;


For strings you must write as,
Code: Select all
$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 [CMD=""]php -f file.php[/CMD] on your console?
jailed
Member
 
Posts: 147
Joined: 09 Oct 2009, 07:25
Location: Internet

Postby SirDice » 16 Mar 2010, 10:08

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.
Senior UNIX Engineer at Unix Support Nederland
Experience is something you don't get until just after you need it.
User avatar
SirDice
Old Fart
 
Posts: 16185
Joined: 17 Nov 2008, 16:50
Location: Rotterdam, Netherlands

Postby GhettoBSD » 16 Mar 2010, 20:53

Thanks for the replies!

Jailed: interesting, php -f header.php returns this:
Code: Select all
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: Select all
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: Select all
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: Select all
<? menu();?>


But the newer version did. So I modified it to this:
Code: Select all
<?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!
You can never say never and never say always.
Check out the new GhettoBSD.org site. Now with Web 3.0!
GhettoBSD
Junior Member
 
Posts: 38
Joined: 27 Jul 2009, 16:31

Postby roddierod » 17 Mar 2010, 19:14

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

Code: Select all
<? menu();?>


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

and it works!


That not a version problem, that because you had short tags enabled on the Linux machine and not the BSD machine.
User avatar
roddierod
Member
 
Posts: 697
Joined: 17 Nov 2008, 12:36
Location: On my Slingerlands!

Postby GhettoBSD » 18 Mar 2010, 17:21

Hmm, so how can I enable short tags on BSD?

Thanks!
You can never say never and never say always.
Check out the new GhettoBSD.org site. Now with Web 3.0!
GhettoBSD
Junior Member
 
Posts: 38
Joined: 27 Jul 2009, 16:31

Postby DutchDaemon » 18 Mar 2010, 17:26

[FILE]/usr/local/etc/php.ini[/FILE]

Code: Select all
; 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
User avatar
DutchDaemon
Old Fart
 
Posts: 10464
Joined: 16 Nov 2008, 20:17
Location: The Netherlands

Postby GhettoBSD » 18 Mar 2010, 17:49

DutchDaemon wrote:[FILE]/usr/local/etc/php.ini[/FILE]

Code: Select all
; 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


you the man, thanks!
You can never say never and never say always.
Check out the new GhettoBSD.org site. Now with Web 3.0!
GhettoBSD
Junior Member
 
Posts: 38
Joined: 27 Jul 2009, 16:31


Return to Web & Network Services

Who is online

Users browsing this forum: nORKy and 0 guests