PHP Scripts don't seem to be working

Status
Not open for further replies.

webgow79

New Member
Messages
12
Reaction score
0
Points
0
HI, I'm new to scripting and have just started using this site as a host -

I've written some php scripts and they work locally but don't seem to work when loaded to the host. Are there some settings I should set ? does PHP need to be enabled?

I've seen in the documentation something about :
"When PHP 4 and PHP 5 are both enabled and served using the CGI, DSO, or suPHP configurations, cPanel lets the user select the default PHP version that processes .php files for all domains assigned to that account.
This interface is available in cPanel’s X3 theme under Software/Services >> PHP Configuration. Available settings are PHP 4, PHP 5, and System Default. "

However these options are not visable in my cpanel - am I doing some thing wrong ?
thanks
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
PHP is enabled for all free hosting accounts.
Scripts should have permissions set to 0755 or 0644.

The default setup is to parse only files with a .php extension.

Also, you should use <?php ?> tags instead of the short <? ?> form.
 
Last edited:

webgow79

New Member
Messages
12
Reaction score
0
Points
0
Hi Thanks for the reply,

When you say the default setup will only parse .php files - are you saying that PHP embedded in htm files will not work ?
If yes - how can I change this so that embedded scripts will work?

Below is a sample script - it is embedded in a htm file.

the word "example" is displayed - but the echo command is not.
Any ideas ..?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Arachnophilia 3.9]">
<meta name="description" content="PHP Example">
<meta name="keywords" content="PHP example">
<title>PHP Example</title>
<link href="style.css" rel="stylesheet" type="text/css">
<head>
<body>

<h1 style="text-align: center">Example</h1>

<p>
<?php
echo "This is a test!";
?>
</p>

</body>
</html>
 

Livewire

Abuse Compliance Officer
Staff member
Messages
18,169
Reaction score
216
Points
63
Clear your cache; loads just fine here:

"Example

This is a test!agritest.x10.bz"
 

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
Hi Thanks for the reply,

When you say the default setup will only parse .php files - are you saying that PHP embedded in htm files will not work ?
If yes - how can I change this so that embedded scripts will work?

Below is a sample script - it is embedded in a htm file.

the word "example" is displayed - but the echo command is not.
Any ideas ..?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Arachnophilia 3.9]">
<meta name="description" content="PHP Example">
<meta name="keywords" content="PHP example">
<title>PHP Example</title>
<link href="style.css" rel="stylesheet" type="text/css">
<head>
<body>
<script type="text/javascript"><!--
var _gaq = _gaq || [];
_gaq.push(
['_setAccount', 'UA-1806325-2'],
['_trackPageview']
);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
//-->
</script>


<h1 style="text-align: center">Example</h1>

<p>
<?php
echo "This is a test!";
?>
</p>

</body>
</html>

change the extension to .php
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Add to .htaccess

Code:
AddType application/x-httpd-php5 .html .htm

While this will let you run PHP scripts with a .html or .htm extension, all your files will be parsed, which is a bit of a performance hit if most of your files do not use PHP.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
.htaccess can be seen if you enable "hidden files".

1. Log onto cPanel
2. Click on ' reset all interface settings ' at bottom of page
3. Open File Manager
4. There should be a popup, check "Show Hidden Files' and 'Skip this Question'
5. If .htaccess is not visible now, it is not there.
 

Jarryd

Community Advocate
Community Support
Messages
5,534
Reaction score
43
Points
48
Hello,

To allow us to better serve our customers i am closing this thread which will allow the staff members to see which threads have or haven't been answered, this does not mean we don't wan't to help with your problem. We are fully aware of your problem and request that if you require to reply to your ticket, please just re-open the same ticket using the open thread button. This can be located in the "administrative" drop down menu at the top of the original post.
 
Status
Not open for further replies.
Top