Welcome Guest, Not a member yet? Register   Sign In
weird php5 behaviour
#1

[eluser]daulex[/eluser]
oookay. I am hosted with heartinternet.co.uk and their php version by default is 4.4.8, I looked up php.net and the latest version was 5.2.6, apparently they have some weird thing, if I create a .htaccess file with:
Code:
SetEnv DEFAULT_PHP_VERSION 5

it is supposed to run version 5 (when I put in the .haccess the phpversion returns v 5.2.5) and yadi dada, I thought, if I will be developing anything, it should be written for php 5 (or at least work with it), however what happens is the following:

my main homepage with 4.4.8: (not built with CI)
http://img300.imageshack.us/img300/9253/galenko4od8.png
now the same page after I put in the .htaccess and the version is 5.2.5:
http://img177.imageshack.us/img177/3854/galenko5mx0.png

a web site I am making that uses CI with 4.4.8:
http://img156.imageshack.us/img156/9624/ll4bz5.png
now the same page after I put in the .htaccess and the version is 5.2.5:
http://img156.imageshack.us/img156/945/ll5ay9.png

here is the error code on the second web site with 5.2.5:
Code:
load->helper('url'); $this->load->helper('form'); } function index() { $data['query'] = $this->db->order_by("id", "DESC"); $data['query'] = $this->db->get('template'); $this->load->view('news',$data); } function longstory(){ $data['query'] = $this->db->order_by("id", "DESC"); $data['query'] = $this->db->get('template'); $this->db->where('id',$this->uri->segment(3)); $data['query2'] = $this->db->order_by("id", "DESC"); $data['query2'] = $this->db->get('template'); $this->load->view('view_news',$data); } } ?>
404 Page Not Found

The page you requested was not found.

I'm a newbie to coding and I have no idea what I should start to fix these things, I was wondering if this is my code-related or there is a screw up on the server. I can provide the code for the first web site, if required.

Thanks Smile
#2

[eluser]Seppo[/eluser]
Probably PHP 5 has short_open_tag Off and PHP 4 On...
Also seems you have a fatal error on PHP 5 on your home page, although it is not an error on PHP 4
Try adding this to the .htaccess

Quote:php_flag short_open_tag On
php_flag display_errors On

The first one is to enable short_open_tag (which would fix your pages inside CI) and the second one is for your homepage, to see which fatal error is trowning (if i'm right and that's the problem)
#3

[eluser]daulex[/eluser]
did what you said, same thing, absolutely nothing changed. (same bug)
#4

[eluser]Michael Wales[/eluser]
Add the following line to php.ini as well:
Code:
php_flag short_open_tag on

The error that is occurring is your server isn't sending your code to the PHP process (that's why it's just echoing it out).

Another thing you could try is turn on short tag rewrite (or something like that) in config.php - CI should dynamically rewrite those short tags for you then.

Finally, you could go back through your code and manually remove any short tags and change them to the longer form.
#5

[eluser]daulex[/eluser]
Michael, thank you, about the short tags: does that mean that you can't use short tags in php5? or is it this hosting-specific thing, by the way, set the short tag rewrite to true and re uploaded the .htaccess to set it to php 5, exactly the same thing, do you think a different("better") hosting could work with it? or is the script just badly written?
#6

[eluser]Michael Wales[/eluser]
It's definitely a host thing - most hosts should have short-tags turned on or allow you to turn them on easily. Plus, it sounds like you are having to jump through a lot of hoops to get PHP5 to work. With Dreamhost it's just a click of a radio control within your control panel and on A Small Orange it's an .htaccess option (but it actually works).

"Badly" written is a subjective term. Some people love short-tags and if it's going on a server in which you know short tags are allowed - they can be great. Any script that is going to be distributed to the public, or you are unsure of the server configuration, you should use long tags (since they will always work).

Back to your issue:
You turned on short tag rewrite and it still didn't work - how about we leave short tag rewrite on and switch to PHP4 (I'm assuming you don't have any PHP5 specific code involved). If it works - great! You can just keep using PHP4 (really, don't fix it unless it's broke, right?). If you are all about using PHP5, I would work with your host - it almost doesn't appear to be a short tag issue any longer and an issue with your server's PHP5 configuration.
#7

[eluser]daulex[/eluser]
thank you Michael, everything works on 4, it always did Smile just wanted to be more "up to date" Smile Michael, what hosting would you recommend?
#8

[eluser]Michael Wales[/eluser]
I use A Small Orange - their US based, I'm not familiar with UK hosts.




Theme © iAndrew 2016 - Forum software by © MyBB