I am having issues while running the live preview of some php files on LOCALHOST. Like I am working on Wordpress theme and while I am able to set the correct base URL and open the file on the browser through index.php, but I am not able to edit and view the other php files.
For example, I have to open index.php which is in http://localhost/test but suppose I want to edit the header.php file. I click on the header.php file and it opens a new page in Browser with URL, http://localhost/test/header.php, which returns a 404 error through wordpress(OOPS PAGE NOT FOUND!)
I have very little work with index.php and mostly with header, footer, functions and everything else. Although this isn't really a big issue, I can go with the traditional way but I really wanted to utilize this Brackets Feature. Hope there's something to get past this :)
This is not an issue this will never open in browser like single file, if you want to check this then header.php and footer.php files are also included into the index.php , you will check from that no need to run them to browser.
Related
I am experimenting with using AWS. To be specific, I am following the tutorial at this link:
https://aws.amazon.com/getting-started/hands-on/build-web-app-s3-lambda-api-gateway-dynamodb/module-three/?e=gs2020&p=build-a-web-app-two
I have tried to add empty PHP tags to the start of the file and renamed the file to index.php instead of the index.HTML of the tutorial. I did a full sequence of refreshing the web app resources and deploying the app on the Amplify console. It did not work. I tried only using the HTML code on index.php and it still did not work. I put back the PHP code, added an echo statement echo "<h1>PHP Code Ran</h1>"; but renamed the file to index.html and it did render. Granted, there was an error in the text output. It also wrote the ending semi-colon and ending quotation, but it worked.
Is there any way for me to use a file named index.php as the home page of a web app using AWS amplify?
A PHP file isn't just an HTML file with a different name: you need to have a server somewhere that's running PHP which will look at the PHP code and run it.
If you're just uploading files to S3, that's not going to happen, the file is just going to be sent straight to the browser, regardless of what you call it and what you put in it.
Putting <?php echo "<h1>PHP Code Ran</h1>"; ?> into a file "worked" only in the sense that when you opened the page in the browser, you saw your browser's best attempt to interpret that as HTML. If you go to "View Source", you'll see that the file is exactly what you uploaded to S3, no PHP has run at all.
If you want to write a PHP application, you need to understand how to run PHP - most likely on an EC2 server, but it could also be in a Fargate container, or something even fancier like bref which lets you run PHP in a Lambda function.
I have made a custom theme with wordpress locally with wamp.I use notepad++ for writing my code.Some days before when I wanted to load my page from notepad I had to go to run->launch in Firefox and had no problem showing the page where in the address bar the URL was:localhost/wordpress.
Now when I try to load my php files from notepad (run ->launch in Firefox) it shows a corrupt html page not all of it ,with some rules of php and without CSS and no images.In the address bar when running my project from notepad the URL is file:///C:/wamp/www/wordpress/wp-content/themes/revenant/page-about-us.php which is incorect ofcourse.Also it does not understand the php code.For example the title for about us page is
<?php echo get_the_title('about-us'); ?>
But when I write manually in the address bar the URL of my project like localhost/wordpress everythng shows as they shown before with no problem.I have not changed any settings in notepad.Why this problem came up with no reason?Why it doesnot load php and css? Thank you!
Notepad++ doesn't know that you have a webserver running or what the document root is, so it cannot take you to the file's URL. When it opens the file in the browser, it is loading the file directly off the hard drive (hence the file://). It is not being served by the webserver that knows how to parse PHP, it is being read directly by the browser, which does not.
i have migrated from host to my new host
everything is working good but when i upload a image to my media it goes with old URL and wont even show up
the thing is the image actually uploads , i know that from filezilla cause it goes into the uploads folder
what is the problem? and how can i fix it?
Edit functions.php
If you have access to the site via FTP, then this method will help you quickly get a site back up and running, if you changed those values incorrectly.
FTP to the site, and get a copy of the active theme's functions.php file. You're going to edit it in a simple text editor (like notepad) and upload it back to the site.
Add these two lines to the file, immediately after the initial "
update_option('siteurl','http://example.com');
update_option('home','http://example.com');
Use your own URL instead of example.com, obviously.
Upload the file back to your site, in the same location. FileZilla offers a handy "edit file" function to do all of the above rapidly; if you can use that, do so.
Load the login or admin page a couple of times. The site should come back up.
Repeat the above steps, but remove those lines. IMPORTANT: Do NOT leave those lines in there. Remove them immediately after the site is up and running again.
So I've created a php webpage with a head section that links to some bootstrap css files and my custom css file. This webpage also has a foot division that links to the necessary jQuery and bootstrap JavaScript files. That's all fine and dandy: I know it works because when I launch this .php in firefox, I can see that Bootstrap has taken control and stylized the text. The problem occurs when I try to break this webpage up into components...
I've created a separate head.html and foot.html which include the same content as before they were broken up, and on the .php page I use the following include statements:
<?php include '../components/head.html'; ?>
<?php include '../components/foot.html'; ?>
Now when I launch the php from my browser, the links clearly haven't worked because the text is not styled. Upon choosing to "view source" of the .php, I see that it has not included the markup from head.html or foot.html, and instead I still see the literal <?php include '';> statements. What have I done wrong? I know the relative filepaths are correct, so perhaps it has something to do with the fact I'm trying to launch the php page locally? Perhaps the components should be .php instead of .html? I really don't know.
Additional info: Win7, tried using notepad++ because Dreamweaver keeps giving me FTP errors every time I ask to "preview in browser"
First you should have a webserver installed along with PHP. You may use xampp or wampp. If you simply open a php file in your browser then it will not execute the PHP statements instead will display the code as it is.
Except for not having a web server along with PHP installed in your system you have done nothing wrong as I see.
The head.html and foot.html can be html files and not .php files that would not be an issue till the file containing the include statment is .php file.
I have a weird unexplainable phenomenon going on.
I downloaded some source code from a website, a basic PHP script. It came with an SQL to reference numbers as part of the script.
I uploaded the file called post.php and SQL file to my server and ran it - but - instead of executing the code in the PHP file, it loads the content of the webpage of the author of the source code. and stays on my server URL.
The code in the file has nothing to do with the author's site, or graphics or links or redirects or anything.
EVEN IF I delete the entire contents of the post.php file, run the empty file and it STILL LOADS CONTENT from the author's website, where I downloaded it from.
Refreshed browser, restarted, reloaded, you name it. How is this physically possible?
-----UPDATE
In addition when I try renaming PHP files on my server, they become permanently broken "oops broken link" error.
It would be very helpful if you could post some more specific details about what the script was, etc. But, here is my guess. Firstly, make sure that your web server is not doing any caching. If the problem persists, try getting rid of the post.php file itself. Then, I would check to see if the PHP script has created any HTML/PHP files on its own. If all else fails, try going into the code that you downloaded and see what its doing.