I don't get it. How do I create PHP documents at my page at Frihost??
I've tried but not even
<?php
echo 'Hej';
?>
..works. What should I do?
You have to save your document with the extension .php (example: test.php).
then upload it onto the server using file manager or a ftp client
and then view it.
I created it via File Manager. Won't that work?
//Uploaded it and it still doesn't work
then did u got to
www.YOUR-URL.NET/PAGE.php
change the stuff in CAPS
No, the page was completely empty...
Did you put your php page in public_html folder?
Sonam
Try the code without the ' and '. I know that wouldn't change anything but just try it:
| Code: |
<?php
echo omfg;
?> |
Also, recheck that first your going to the correct page, and second that you NAMED IT SOMETHING LIKE HOLY.php
You MUST have .php and not .html or .htm. If that doesn't work then theres something wrong.
Maybe posting you site URL could help.
your page source shows this:
| Code: |
<html>
<head>
<title>Catscratches</title>
<style>
* { font-family: verdana; font-size: 10pt; COLOR: gray; }
b { font-weight: bold; }
table { height: 50%; border: 1px solid gray;}
td { text-align: center; padding: 25;}
</style>
</head>
<body>
My first thing in PHP. Tremble and beware!!
<?php
$hej='lol';
echo $hej;
?>
</body>
</html> |
php is not shown through source code. It is showing because the page you are trying to use it on is named index.html. You need to change index.html to index.php in order for the php code to work.
| Quote: |
$hej='lol';
echo $hej; |
Thats the same thing as :
You just added a variable which is a waste of time. Though that code works, its just a waste.
| Diablosblizz wrote: |
| Quote: | $hej='lol';
echo $hej; |
Thats the same thing as :
You just added a variable which is a waste of time. Though that code works, its just a waste. |
Actually,
| Quote: |
$hej='lol';
echo $hej; |
Is equal to:
Not,
Well I added the variable to see if there were any difference. But it wasn't still not working...
| Quote: |
Actually,
$hej='lol';
echo $hej;
Is equal to:
echo 'lol';
Not,
echo 'hej'; |
Its the same thing.. what I ment was theres no need for the variable, the echo does it all.
Cat, make sure that you have saved your index file as .php NOT .html or .htm
Double check that.
I just saved your original "Hej" example to my site, and it worked. Have you tried viewing the source code of the "blank page" you are getting to see if there may be any clues there?
I also tried your "Tremble and beware" from both your site and mine. It worked on mine, but the PHP part did not show up on yours.
Then I decided to check the name of your index page. Of course, I don't have actual access to your account or files, but I could take some guesses, so I actually tried both "index.html" and "index.php" to see what would happen.
Obviously, you have been attempting the advice that the others here have given, since "index.php" is there. On the other hand, "index.html" is still there, as well, and will take precedent over "index.php" so, when I just go to your site without specifying a filename, the "lol" doesn't show. However, if I try "index.php" the "lol" does show, so your code is actually working. (In case you've tried it and missed it, it is on the same line as "Tremble and beware" since there were no "BR" or "P" tags to move it to the next line.)
Thus, it appears that it is working fine for you, but you may not realise it, or may be experiencing other difficulties. In addition to what the others have said to remind you to name the files using a ".php" extension, I would also remind you to remove "index.html" so that the system will pick up "index.php" instead.
| wumingsden wrote: |
| You need to change index.html to index.php in order for the php code to work. |
May I repeat, rename index.html to index.php, it will then work!
Thanks for the help. I'm a ****** noob in PHP. I missed that it was on the same line, lol...
When I click to view my files in the File Manager, the old file is showing up but when I write the real adress in the adressbar, the real one comes up. Why is the old one showing up when I'm just clicking on it in the file manager? And PHP doesn't work there either.
| catscratches wrote: |
| When I click to view my files in the File Manager, the old file is showing up but when I write the real adress in the adressbar, the real one comes up. Why is the old one showing up when I'm just clicking on it in the file manager? And PHP doesn't work there either. |
It's not the old file, it's just that PHP won't work because the address that you go to would be something like:
http://catscratches.frih.net:2222/CMD_FILE_MANAGER/domains/catscratches.frih.net/public_html/index.php
For it to work it has to be accessed from http://catscratches.frih.net/index.php
It looks like the old file because the old file was not parsing PHP, just like http://catscratches.frih.net:2222/CMD_FILE_MANAGER/domains/catscratches.frih.net/public_html/index.php isn't. (This is not an error on your hosting account, it is supposed to do this).