Jump to content

Recommended Posts

I'm trying to host my website on GoDaddy, and the php files of my website instead of being executed and returning the output it is returning the raw code as seen in the network tab of the browser...

The files were working perfectly fine on my xammp localhost, I did whatever configurations were shown on YouTube tutorials like I uploaded the mysql database and created username and password with full priviledges and used it on the php files to connect and I made sure whatever extensions were being used on my localhost is also checked in GoDaddy... 

I contacted GoDaddy Support as well but they said there seems to be no issue on the server side... Does anyone have any suggestions for me to try out?

Link to comment
https://forums.phpfreaks.com/topic/326860-php-not-executing-returning-raw-code/
Share on other sites

15 hours ago, Barand said:

Are you using

<?php
   ...
?>

or

<?
   ...
?>

in your code when you enter a php code section?

The short version (<?) is no longer a default and requires an ini file setting to enable.

I'm using the first version...

<?php
	...
?>

 

12 minutes ago, mac_gyver said:

do these files have a .php extension, i.e. you didn't configure your localhost system to treat .htm/.html extensions as being php code?

I did save them as .php files, as for checking whether they are being treated as php files or not how do I check that on GoDaddy? I added a handler as well to a .htaccess file that I created (Since there wasn't one by default) to treat them as php files: 

AddHandler application/x-httpd-ea-php82 .php

The php version is set to 8.2 and the code I'm using is also compatible with php version 8.2 to the best of my knowledge.

Edited by Dragon_Queen

my reply was a possible reason why php would work on your localhost system but not on actual web hosting. you have already checked, by trying, that the files are not being treated as php on the web hosting.

you should not have needed to create a .htaccess file or put an addhandler ... line in it. this may in fact be why php isn't working. did you do this as an attempt to get the php to work after you discovered that it didn't or did you do this prior to trying to run any php code?

has any php code ever worked on your web hosting?

i would use your cpanel file editor to create a new .php file, and put the following in it, then request the URL of the this file in a browser to see if php works -

<?php
phpinfo();

 

16 hours ago, Dragon_Queen said:

I did save them as .php files, as for checking whether they are being treated as php files or not how do I check that on GoDaddy? I added a handler as well to a .htaccess file that I created (Since there wasn't one by default) to treat them as php files: 

AddHandler application/x-httpd-ea-php82 .php

The php version is set to 8.2 and the code I'm using is also compatible with php version 8.2 to the best of my knowledge.

I would remove that from the .htaccess file.  That is not the type of setting you should need.  GoDaddy should already be configured to support php scripts, purely by the extension of .php.

On 2/25/2025 at 5:00 PM, mac_gyver said:

my reply was a possible reason why php would work on your localhost system but not on actual web hosting. you have already checked, by trying, that the files are not being treated as php on the web hosting.

you should not have needed to create a .htaccess file or put an addhandler ... line in it. this may in fact be why php isn't working. did you do this as an attempt to get the php to work after you discovered that it didn't or did you do this prior to trying to run any php code?

has any php code ever worked on your web hosting?

i would use your cpanel file editor to create a new .php file, and put the following in it, then request the URL of the this file in a browser to see if php works -

<?php
phpinfo();

 

I actually created this file since the php files weren't working in the first place even without them. This is actually the first time I am uploading the website on the web hosting. I also did create temporary php files like you said for testing, but they don't work. Like, when I try to access them via browser it just downloads it instead of showing the output of running that php code.

On 2/26/2025 at 9:13 AM, gizmola said:

I would remove that from the .htaccess file.  That is not the type of setting you should need.  GoDaddy should already be configured to support php scripts, purely by the extension of .php.

Initially the file itself wasn't there but the php code still had the same issue...

On 2/26/2025 at 8:52 PM, Moorcam said:

You are opening the file using the localhost URL, right? Not right-clicking on the file and selecting open in Chrome or whatever?

I'm using the link of the website that I'm hosting in order to access the php files. 

When I'm running this code in xammp localhost everything was working perfectly... I had only changed the username and password to match the database credentials of the database I uploaded to GoDaddy. I did check and ensure the username is in small letters and that the username and password matched the ones I put in the php files...

On 3/4/2025 at 6:32 PM, MeghaPatil said:

 Rename .htaccess or add AddHandler application/x-httpd-php .php.

What should I rename it as?

I did originally add that handler before making it more specific as php82 since I'm using php version 8.2 on the web hosting. Both ways were having the same issue...

is phpmyadmin working?

your initial symptom is that the raw php code is being output to the browser. did this change to the file being downloaded?

about the only thing that comes to mind (ignoring that you apparently directly created a file on the server and it didn't work) is that when you uploaded (ftp) the files to the web hosting they got changed, possibly due to using a binary transfer mode instead of text transfer mode.

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.