Dragon_Queen Posted February 24 Share Posted February 24 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? Quote Link to comment https://forums.phpfreaks.com/topic/326860-php-not-executing-returning-raw-code/ Share on other sites More sharing options...
Barand Posted February 24 Share Posted February 24 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. Quote Link to comment https://forums.phpfreaks.com/topic/326860-php-not-executing-returning-raw-code/#findComment-1650411 Share on other sites More sharing options...
Dragon_Queen Posted February 25 Author Share Posted February 25 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 ... ?> Quote Link to comment https://forums.phpfreaks.com/topic/326860-php-not-executing-returning-raw-code/#findComment-1650459 Share on other sites More sharing options...
mac_gyver Posted February 25 Share Posted February 25 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? Quote Link to comment https://forums.phpfreaks.com/topic/326860-php-not-executing-returning-raw-code/#findComment-1650461 Share on other sites More sharing options...
Dragon_Queen Posted February 25 Author Share Posted February 25 (edited) 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 February 25 by Dragon_Queen Quote Link to comment https://forums.phpfreaks.com/topic/326860-php-not-executing-returning-raw-code/#findComment-1650462 Share on other sites More sharing options...
mac_gyver Posted February 25 Share Posted February 25 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(); Quote Link to comment https://forums.phpfreaks.com/topic/326860-php-not-executing-returning-raw-code/#findComment-1650463 Share on other sites More sharing options...
gizmola Posted February 26 Share Posted February 26 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. Quote Link to comment https://forums.phpfreaks.com/topic/326860-php-not-executing-returning-raw-code/#findComment-1650503 Share on other sites More sharing options...
Moorcam Posted February 26 Share Posted February 26 You are opening the file using the localhost URL, right? Not right-clicking on the file and selecting open in Chrome or whatever? Quote Link to comment https://forums.phpfreaks.com/topic/326860-php-not-executing-returning-raw-code/#findComment-1650527 Share on other sites More sharing options...
MeghaPatil Posted March 4 Share Posted March 4 Rename .htaccess or add AddHandler application/x-httpd-php .php. Quote Link to comment https://forums.phpfreaks.com/topic/326860-php-not-executing-returning-raw-code/#findComment-1650774 Share on other sites More sharing options...
Dragon_Queen Posted yesterday at 10:11 AM Author Share Posted yesterday at 10:11 AM 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. Quote Link to comment https://forums.phpfreaks.com/topic/326860-php-not-executing-returning-raw-code/#findComment-1651194 Share on other sites More sharing options...
Dragon_Queen Posted yesterday at 10:12 AM Author Share Posted yesterday at 10:12 AM 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... Quote Link to comment https://forums.phpfreaks.com/topic/326860-php-not-executing-returning-raw-code/#findComment-1651195 Share on other sites More sharing options...
Dragon_Queen Posted yesterday at 10:16 AM Author Share Posted yesterday at 10:16 AM 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... Quote Link to comment https://forums.phpfreaks.com/topic/326860-php-not-executing-returning-raw-code/#findComment-1651196 Share on other sites More sharing options...
Dragon_Queen Posted yesterday at 10:17 AM Author Share Posted yesterday at 10:17 AM 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... Quote Link to comment https://forums.phpfreaks.com/topic/326860-php-not-executing-returning-raw-code/#findComment-1651197 Share on other sites More sharing options...
mac_gyver Posted 19 hours ago Share Posted 19 hours ago 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. Quote Link to comment https://forums.phpfreaks.com/topic/326860-php-not-executing-returning-raw-code/#findComment-1651225 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.