How Open PHP File - php

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.

Related

Troubles with XAMPP(or?)

I just started taking a PHP course and I'm having a lot of difficulties. I won't get anywhere unless this is resolved.
I got the course files downloaded and added them to htdocs folder but I can't run any new files I created. I get
Object not found! 404 error
I see them under localhost/coursefiles/whtever.php. I've google searched all day but can't find anyone else having this specific problem.
Would uninstalling and reinstalling XAMPP work? This is extremely frustrating and making me crazy.
First Check xampp manager Is your MySQL and Apache is in running state ?
Then Type Localhost in your browser , if Xampp Homepage is Coming It means Xampp is working Fine!
And again Checj your course files Extension they should have .php extension (if they are php files).
Create An folder In your Htdocs Folder With Abc(for example) and Write in browser's Url window "http://Localhost/Abc
if your Folder is opening and it's showing Files Then There must be a Problem with files! :)

PHP website Warning: require(/../core/database/connect.php): failed to open stream

Hi I want to put my website(web application in PHP) on a server of my school and it’s for a project for school. So I had read the instructions of my school where I had to put my source code. I had to put in a folder called ‘Html’ and according to my school that is used for php hosting. After putting my files in that folder I went to browse to my website.
But it doesn’t show me the website when I browse to it. Instead it had given me a error message, see link below:
http://i.imgur.com/dfYxc02.jpg
After reading the error message I thought it had something to do with this line of code in connect.php file:
mysql_connect('145.92.203.240', 'user', mypassword');
I thought that was looking fine, but I also tried “mysql_connect('localhost, 'user', mypassword');”, but I still receive the same error message.
Furthermore I had tried in “/etc/init.d” to restart apache. For this I used the following command:
apache2 –k restart
But I couldn’t restart apache because I don’t have permission.
I also had tried in “/var/www/localhost/htdocs” to show index.html on the browser. But that didn’t work as wel. I also couldn’t remove te index.html file and replace it with my source code.
Could someone please tell me the solution in steps?
Okay here we go:
You're trying to include a file and the location is wrong
For instance, require('config.php'); will assume the file is in the same folder as the script. require('./folder/config.php'); will assume the file is in the folder. So you may want to check exactly where connect.php is.
The error about include_path
It seems as if you have a var include_path defined somewhere, might want to check that out. If you migrated it, you need to change the var to the new location.

Php Query about XAMPP

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.

Opening Yii Application causes download of index.php

I recently downloaded Yii in my linux-ubuntu system. After extracting the files to /var/www/vishnu/, I went for creating the first webapp.
What I have done is executing /var/www/vishnu/yii/framework/yiic webapp anyname in my command line. It succesfully created the application under /home/ti/anyname
But whenever I am trying to access it, It downloads the index.php file instead of opening the webapp home page! Why does this happen? I tried, the following Urls..
localhost/vishnu/anyname/ - Returns Not Found
home/ti/anyname/index.php- Downloads the file
home/ti/anyname/index-test.php- Downloads the file
I can see the files in file:///home/ti/anyname/ But can't open anything. When ever I click on it, it is being downloaded! Please share your solutions if you have any...
Thank you very much. I got it from this blog.
I changed the command such that, the webapp will point to my localhost itslef.
ie php /var/www/vishnu/yii/framework/yiic.php webapp /var/www/vishnu/yii/anyname/
Now its working... :)

Apache doesn't execute my copied PHP files, but testing.php works

I've just installed LAMP on my Ubuntu 9.10 machine, and everything works fine except when I copy my PHP files from another computer.
The LAMP guides I've followed also made me create a phpinfo() test file, which works, but when I try to type in e.g. index.php absolutely nothing happens - just a blank page in FireFox. :(
The files are in the exact same directory.
I'm thinking it's probably something with permissions and so on, but since I'm new to both PHP and Ubuntu, I'm kind of lost. It's like I can't create a PHP file with my file browser, but only by using the terminal - like when I created the testing.php from the LAMP guide.
Whaddayaknow... I made an error, tried to:
echo "Hello" world
which, even though I'm a PHP noob, I clearly know is wrong.
I think I'll have to figure out how to enable some sort of error reporting, a blank page is clearly not good enough.
You mean you have a index.php (copied from another computer) and a test.php (edited by hand, with a call to phpinfo()) in the same apache directory, the second works from your browser and the first doesnt ?
That can be a permission issue, or some compilation error in your php.
About permissions, for files should be readable from the apache server (more precisely, form the user that runs the apache server). You can type chmod a+r index.php.
YOu can also check your apache error logs (location dependent on installation). In any case it's vital to know where the error logs are if your are developing a web site.

Categories