My PHP code is commented out - php

Before everything happened, I was running this wordpress install for developing themes using xampp. But I decided to upgrade the memory of this machine from 2GB to 6GB since I need extra room for applications. I back-up my code in a separate partition by copying them. Since I have a 32bit OS at the time, I format the computer and installed a 64bit version. All is well and fine the OS side.
When I setup my web dev environment something goes wrong.
When I imported my htdocs back, first by just fully copying them to a new fresh install of xampp and notice that all of the codes that put are not working. My CI code is displaying my PHP code in the browser. My theme in wordpress is also commenting out my PHP code when I view the source. The themes included in my fresh wordpress install works so there's something I am missing here.
From the looks of it, the php is being executed properly since anything that I install works. Just that the ones that came from a previous xampp is not.

Open up the php.ini file and set short_open_tag = On. Then restart apache.

If you are opening a local script directly in the web browser, maybe through your editor, double-clicking on the file or dragging and dropping the file ito the browser - it will be treated as HTML only.
Instead, open the file by typing... http://localhost/your-file.php into the address bar. I personally create a projects folder in the htdocs folder and then create a bookmark for... http://localhost/projects/ and this will display all my projects that are saved into my projects folder.
Note: if you changed the mail port for the Apache server, you will need to add that to the path as well. eg. If your main port is 8888, your would do this... http://localhost:8080/your-file.php
I had the same problem and this worked for me. Good Luck

For me, it was because the file was named as ".html". You must have an extension ".php"

Related

Php\Ubuntu virtual links

I have latest Ubuntu 18, also Apache2, php 7.2, mysql.
I have rather old simple php application, written on php4 (at least not older than php5).
I have a task to run this application in this environment, to install php4 is not a variant. Possibly there are some compability mode to run this application by php7.2 as php4?
I succeded to open index.php in FireFox, but also it seems, that it is not shown correctly. I run that application also on Windows\IIS and it works perfectly. But on Ubuntu Application has a menu and i see only part of it. Also any item in that menu is created through localization links, like:
application\en\sitemap
application\en\news
Physically i have folders sitemap, news and etc, just under application root folder. But FireFox is not able to open application\en\news, because it seems it is trying to reach folder EN, which is not exist, of course. So neither menu item could be opened. Though on Windows it works from the start!
Tell me, please, direction for futher search.
Is there a compability mode php7.2-php4?
How should this virtual links en-ru work - should i configure php or there should be some points in application config.php for this issue?
Thanks

Files not loading on php file

I'm having a few problems when I upload my design to my hosting.
Sometimes different things won't load css files, images, jsfiles, etc.
This makes it so my design looks like this. I've checked all my file paths, and they all are correct.
Sometimes my index.php won't even load.
Here's a preview.
Here's another preview when I refresh.
Thank you for the help.
I have contacted my website hosting. They have restarted the server and everything is working now.
The problem would have been that there were 2 servers running on one or something they said. I have no idea what they were talking about. But it helped!
Thanks to everyone who helped out!
If you have Linux Hosting, then the references for css, images, javascript files must have the same exact name. It is case sensitive.
E.g., Style.css is different than style.css and style.CSS for Linux hosting hence it will not load those files and will give file not found error.
And it applies to folder names as well. E.g. if logo.jpg is in a folder named "Images" then reference should have "../Images/logo.jpg". And if you have "../images/logo.jpg" then you get "File not found".
Option 1: Use Xampp
www.apachefriends.org/de/download.html
But if you do, download the version 5.5.38, it works better than the new version.
After installing, close applications that need Port 80, start the Apache, and pull your folder with your stuff in "C:\xampp\htdocs".
localhost/"yourfilename" is the domain you could use it.
Option 2: Use a virtual machine and install a linux server.
Virtual Machine Download
Ubuntu Server Download
Now you can install your Server and open it.

MAMP moodle project

I am working on a moodle based project, which I inherited from someone else. Having copied the files into htdocs folder and started MAMP, the files still don't show in the browser. Instead, the browser automatically initiates a download. I might be required to change the config file, however, since I do not have much experience with php and SQL I am not sure what exactly. My part of the project is to develop html and css, but need to be able to run it locally first.
What do I need to do to get the files run locally? The route I use is localhost:8888/whatever/whatever/index.php
In case someone else runs into the same problem - Apache downloads php files instead of reading them - here is what helped me.
.htaccess file may need changes if the application has changed servers.
Delete (at least rename if you don't want to remove it) config.php and run the application through the browser. It should initiate install automatically.
To run php and SQL I used MAMP.

Live site is an ubuntu, setting up wamp on local machine var/www not resolved

I have a live site that is set up using ubuntu. All my files include a bunch of classes and they are all referenced at var/www/classes/class_name. My file structure is a lot different being on a wamp server.
I don't want to have to go through all my files and change the location to match that of the windows machine.
Is there an easy way to make my wamp server look in a windows directory structure when my php file says to look in var/www?
I don't want to have to go through all my files and change the location to match that of the windows machine.
You should be using relative paths anyway so that this isn't a problem. I strongly suggest going back and fixing your paths so that you can move your code to wherever it needs to be.
I have a live site that is set up using ubuntu.
You should be running your development code in an environment similar to where it will run in production. I suggest using a tool like Vagrant to manage a virtual machine for you that runs Ubuntu and whatever web server you run in production. When you do this, you can also map directories over in any way you like. (You should still solve your path problem though.)

How to live preview PHP using MAMP

I am creating a WP theme (for personal use only) and I need to be able to preview PHP files.
Here's where I'm at so far:
I use Adobe's Brackets.
I have a server on Bluehost.
I have downloaded FileZilla and linked it to my bluehost server.
I have created a directory on my bluehost server: /public_html/wp-content/themes/Cookie
I have downloaded an FTP Sync extension in Brackets, and synced it to the root directory of my theme (/public_html/wp-content/themes/Cookie).
I have installed MAMP on my mac (although never used it and have no idea what to do next).
I have contact Adobe Brackets and they have said this: "If you have a MAMP (or other PHP server) set up, you just need to change the File->Project Settings"
But I have no idea what to do now I have downloaded MAMP.
As you can probably tell, I'm a bit of a noob so please explain things delicately :)
Thanks in advance!!!!
download Wordpress from wordpress.org, install it locally on your MAMP, it shoud have a folder called www or data, reading the docs is recommended. Then, download your theme from your hosting and to the wp-content/themes/ folder, now start a new project, it's gonna be easier.
When your theme is ready, upload it to the server again.
Hope this helps.
I had the same issue but figured it out with the help of your question.
So this is for brackets newcomers like myself :)
Guide for Mac:
Setting up Server
Download and install MAMP
Go to MAMP Preferences
Change the "document root to your project
Brackets Setting:
Open Brackets
Make sure the "Enable Experimental Live Preview" IS OFF! (File > Enable...)
Go to File > project setting
copy and paste this default MAMP server address (http://localhost:8888/) [or change according to your MAMP setting]
Thats it you have got your live preview up and running!

Categories