Php Query about XAMPP - php

I have created a PHP file as avnish.php in htdocs folder of XAMPP.
But while i am executing this file on local host as "localhost/avnish.php" in my browser, my browser searching on Google.
Kindly help me out regarding this.

You should write full text:
http://localhost/avnish.php
Some browsers recognize it as keyword for search. Try the above example. and if the problem still exists use another browser.

Related

How Open PHP File

I like to try a simple PHP Project. I installed apache, mysql and phpmyadmin on my computer (linux- fedora). Everything worked fine so far - i can open and log in to phpmyadmin.
I created a simple "Hello World" php file to try. Sadly the browser wont open it. All I get is: "Not Found The requested URL /home/.../test.php was not found on this server." This is the URL into my browser "http://localhost/home/.../test.php"
Since I never worked with php before I figure it's a simple mistake. It seems I have saved the file at the wrong place. From what I have found out I need to save it at /var/www - but I cant find that directory on my computer.
Thank for the help in advance!
Save your File in htdocs folder and then run it in browser. or you can also make other folder inside htdocs folder.
Example: localhost/htdocs/test.php.

Using Brackets for PHP files

I currently have wampserver running and I'm trying to do live preview of a php file using Brackets.io. However when I click live preview I'm getting
Project settings for: Getting Started
Live preview base URL: ______________
I'm following this tutorial on running PHP scripts.
My php file is in C:/wamp/wwww/php_proj1/php1.php so I've been trying to put this in my "Base URL"
http://localhost/php_proj1/php1.php
However everytime when I type that and enter it, it just asks me for the "Live Preview Base URL" again and nothing happens. I also tried putting the URL in my 'File->Project settings' and that also didn't work. I'm just running a basic php script that echos some words.
It works when I manually type
http://localhost/php_proj1/php1.php
in my Chrome URL but not when I use Bracets live preview.
What am I missing or doing wrong? Do I need to config anything in my wampserver? I've just started learning php and using wampserver so I'm not entirely sure what I'm doing wrong.
Thanks!
EDIT: I'm following these 2 tutorials on doing this and it's just not working for me.
tutorial 1 and tutorial 2
EDIT2: Found my mistake.. I did not do File->Open Folder to open the folder that I was working on... Thanks to everyone that helped me with this, I will definitely not make this mistake again. sigh
The Live Preview Base Url should be set to the same url that you would use to launch your project in a browser.
So if you have a project in C:/wamp/wwww/php_proj1/ you would launch that project in a browser by entering http://localhost/php_proj1/php1.php therefore that is what Brackets is expecting to be entered into the Base Url field minus the actual script file name.
Remember the DocumentRoot of localhost is pointing to the folder C:/wamp/www/
So enter
http://localhost/php_proj1/
into the dialog that requests the Base Url.
Assuming you are editing the file php1.php at the time you clicked the Live Preview icon that is the script that will be run in the browser.
Oh and of course you have to have WAMPServer and therefore Apache up and running when you do this as it is running the code through Apache so that the PHP code can be interpreted.
Found my mistake. I did not do File->Open Folder to open the folder that I was working on...
Try the same thing but with a simple HTML file.
Try launching your project with PHP's built-in server. Open a terminal/cmd window and go to the folder php_proj1. Now execute php -S localhost:8000. Now set your Live preview path to http://localhost:8000/. If this one does work, then there may be a problem with Wamp.
Now remember that no matter what, you're not supposed to contain a file in the Live Preview path, but only a folder path. When you contain it, you get to this URL: http://server/file.php/file.php (double) and that's not exactly what you want...
If none of these work - there may be a problem with either your computer, Brackets, Chrome, or both. Try to reinstall them (Brackets first).
My two cents, is the name of the project php_proj1 ? If not you'll have to use http://localhost/ as your base URL.
Also (When you are using Brackets) check the content of the Chrome Network tab. F12 Developer Tools -> Network -> Filter -> Documents
Try to investigate the URLs, probably that'll give you some insight

How to access phpinfo.php?

I am trying to access
http://localhost/phpinfo.php
but I can't find a way to get there on the local machine I made the update on.
This is part of a FastCGI installation to Host PHP Applications on IIS 6.0.
I followed steps here: 'Test PHP CGI' in http://www.iis.net/learn/application-frameworks/install-and-configure-php-applications-on-iis/using-fastcgi-to-host-php-applications-on-iis-60
I copied phpinfo.php as indicated in the link above in the F:\Inetpub\wwwroot directory as indicated here http://msdn.microsoft.com/en-us/library/ms474356(v=office.12).ASPX
then tried to access
http://localhost/phpinfo.php
but I don't get anywhere (I get: 'The webpage cannot be found' error message).
Any help is appreciated.
Thanks,
Izumi.
You should be able to get all the information by saving a file with the following:
<?php
phpinfo();
?>
and simply view that page.
While you are testing, you can drop it anywhere you like, but obviously remove it from a production box as anyone will be able to see it.
I had to add the .php extension in the IIS Web Sites Properties as indicated here http://www.iis.net/learn/application-frameworks/install-and-configure-php-applications-on-iis/using-fastcgi-to-host-php-applications-on-iis-60 under 'MANUALLY CONFIGURE THE FASTCGI EXTENSION TO WORK WITH PHP'
I am not sure why the script didn't do it for me. Maybe because I had two domain names on that server.
Thanks for your help!
Izumi.

WAMP doesn't update html file after editing

i have another question. I am using WAMP as my local server. I have this file index.htm. The problem now is when I try to edit this file and reload localhost in the browser nothing' changed. But when i double click the html file to open it without WAMP server it diplays the edited one. I don't know why..
it's working now. I only have to put all files inside WWW folder and not inside another folder. Thanks everybody for the help..
Check that the index.htm is in the correct (WAMP) directory (usually c:\wamp\www)
Check WAMP is running
Personally i use XAMPP for mac (they have a windows version too) and place your Websites in /Applications/XAMPP/htdocs/ and access them via (http://localhost/) or you put your Websites in the Sites-Folder in your Home and access them via (http://localhost/~username/).
Obviously if you use windows the paths will be different, but XAMPP will provide you with a help screen on first boot.

Just one PHP page won't run - it wants to download

All PHP pages are all running just fine on my site, except for one for which Firefox says "You have chosen to open checkpage.php which is a PHP script" and then wants me to select an application with which to open it.
The site is running PHP Version 5.2.10 on Centos 5.5.
I'm using exactly the same code on another site (PHP Version 5.2.10-2ubuntu6.4 on Ubuntu 9.10) and it's fine.
I've Googled myself silly trying to work out what the issue is!
Does anyone have any ideas why this one page might be causing a problem? The page is about 200 lines long but I'll post it here if it'll help...
All thoughts much appreciated
Mike
PasteBin: http://pastebin.com/A6uNj9CN
Last time I had this problem, I just installed PHP on my server. Worked fine after I rebooted it. Hope that helps.
Does the file that's downloaded have any content? Or is it zero bytes? It's possible something's causing PHP to puke on that script before it sends out any headers and so the browser has no choice but to interpret it as a download of a .php file with no content.
Check the server's error logs (and PHP's as well) to see if anything's showing up in there.
Is there a separate htaccess in the folder that stops apache from sending it to php or changes the mime-type? Does the file have a different extension than other files on your site?
Use something like a packet sniffer, or HTTP Debugger, to see what headers are actually sent by the webserver. That will help you, and us, debug the issue.
Call curl -I http://blahblah/foo.php and look at the content-type header. That will help point you in the right direction. Is it text/html or something else?
Try to change the permission of the file from 775 to 644 or try changing the permissions. Note: change to the correct permission type to avoid public viewing of the files

Categories