Click to See Complete Forum and Search --> : Complete noob. Getting php to work for my web page


Wej
03-21-2008, 06:24 PM
Ok, i am just getting started learning php. I am using StartLogic as my web host provider. I have been trying for hours to get the php to work, but the webpage says this: "The server encountered an unexpected condition which prevented it from fulfilling the request.
The script had an error or it did not produce any output. If there was an error, you should be able to see it in the error log. "

I am following this book, slightly outdated, but not by much. At any rate, this is the simple code i want it to process:

<?php
echo "<p>will this work?</p>";
?>

<?
echo "<p>This one?</p>";
?>

<script language ="php">
echo "<p>Or even this?</p>";
</script>

What am i doing wrong??? I am so confused!

sasam1400
03-21-2008, 07:31 PM
The code itself is correct... all 3 of them :)
there must be something wrong with server... maybe you have to turn php on or something.

you can try adding
ini_set('display_errors', '1');
error_reporting(E_ALL);
at the beginning of your code, so if errors are turned off in php, you will see error messages.
also... did you give your files .php extension?

bathurst_guy
03-21-2008, 07:31 PM
Just try one of them at a time to see which works, servers can be set up differently. Usually <?php ... ?> works on most if not all. So try deleting the others and see what happens?

Wej
03-21-2008, 07:43 PM
The code itself is correct... all 3 of them :)
there must be something wrong with server... maybe you have to turn php on or something.

you can try adding
ini_set('display_errors', '1');
error_reporting(E_ALL);
at the beginning of your code, so if errors are turned off in php, you will see error messages.
also... did you give your files .php extension?

I was woundering if the php is turned on for StartLogic, and i am pretty sure it is, as it says the current php version is 4.4.7, and also Path to PHP /usr/local/bin/php (which i am not sure why they give you this).

I am trying to start a live chat with them, but i have never gotten to a customer service person...even after staying there for atleast 5 hrs, no matter when I try.

EDIT: Oh, and yes, i have saved it as a .php file

Just try one of them at a time to see which works, servers can be set up differently. Usually <?php ... ?> works on most if not all. So try deleting the others and see what happens?

That didn't change anything either.

Thanks for the help though. If anyone can figure out the problem with my vague question, i will love you!

sasam1400
03-21-2008, 07:54 PM
try installing easyPhp (some version) on your computer... so you don't have to upload files on server, you will have server on your computer... you can try them all at http://localhost/yourfile.php
that way you can experiment with php as much as you wish... and in meanwhile you can try enabling php on your remote server.
i dont know if this is allowed (since it can be considered as commercial) but you can register for free at www.awardspace.com and there's fully functional php (and a lot more) :)
good luck

Wej
03-21-2008, 07:57 PM
try installing easyPhp (some version) on your computer... so you don't have to upload files on server, you will have server on your computer... you can try them all at http://localhost/yourfile.php
that way you can experiment with php as much as you wish... and in meanwhile you can try enabling php on your remote server.
i dont know if this is allowed (since it can be considered as commercial) but you can register for free at www.awardspace.com and there's fully functional php (and a lot more) :)
good luck

Ill try easyPHP.

The book I am learning from has you download apache, then PHP stuff, and modify it so you can use PHP on your own server. But apache isn't working for me, and i have done everything the book has asked me to do. (Apache itself is working, but not changing it to work with PHP. It just doesn't work!)

Wej
03-21-2008, 08:02 PM
Will i have to uninstall apache and mysql for this easyPHP to work?

sasam1400
03-21-2008, 08:12 PM
hm... i dont' know... but i think it's better to uninstall them, because easyPhp will install apache and mysql again, but it's own version. it works great, and it's very easy to install and run... and it's free :D

Wej
03-21-2008, 08:13 PM
hm... i dont' know... but i think it's better to uninstall them, because easyPhp will install apache and mysql again, but it's own version. it works great, and it's very easy to install and run... and it's free :D

3 of my favorite words: great, easy, and free:)

Oh, and is there a tutorial that teaches you how to use this thing?

sasam1400
03-21-2008, 08:24 PM
there's no need for tutorial for easyPhp... it only does what you tried to do following your manual... it installs php, apache, and mysql in one step.... and also phpMyAdmin (for administering mysql databases).
But you certainly could find some tutorials for php and mysql.
i recommend http://w3schools.com/php/default.asp
it's very informative, as for beginners, as for intermediate coders.

Wej
03-21-2008, 08:36 PM
Ok, cool.

I have tried to create a simple code, and i put it in the C:\Program Files (x86)\EasyPHP 2.0b1\www folder. When i go to the page, it just shows Current date: It is not processing the PHP...Here is the code i put in it

<html>
<head>
<title>My first page in PHP</title>
</head>
<body>

Current date : <? print (Date("l F d, Y")); ?>

</body>
</html>

EDIT:

And when i try to do the last code, most of it works...i think...well, it produces this:
will this work?
This one?

"; ?>

Or even this?

Wej
03-21-2008, 09:16 PM
Well...i fixed that problem. The easyPHP is not compatiable with the <? ?> thing i guess. I change it to <?php ?> and it worked.

I still need to get startLogic to work with the php file though, atleast i can move on while i wait for them to actually not be so damn busy.

Wej
03-21-2008, 09:48 PM
Thank you for helping me atleast get started programming. I love doing it, and i am getting paid for it:D

EDIT: Just got through to customers assistance. Yes, the CGI wasn't enabled. I couldn't find it, was looking forever, but now the problem is fixed