Forum Moderators: mack

Message Too Old, No Replies

at a loss with PHP

         

ckhagen

10:14 pm on Sep 16, 2003 (gmt 0)

10+ Year Member



/I'm just (I'm talking, JUST) starting to learn PHP.

I'm writing that "first" script and I keep getting a parse error when I load it up.

Here's my code:


<html>
<body>

  <?php

  print ("where's my cheese?");

 ?>

</body>
</html>


The parse error is for line 6 (the one starting with print).

What could I have possibly done wrong?

Can anyone give me a rundown of exactly what php is and explain the major points?

Thanks.
CK

txbakers

1:11 am on Sep 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You don't use "print" to print a line in PHP, you use the "echo" command.

Lots of good resources on PHP can be found at www.php.net

We also have a forum here at WebmasterWorld devoted to PHP topics.

ckhagen

1:52 pm on Sep 17, 2003 (gmt 0)

10+ Year Member



Thanks.

That's bizarre because I'm going off of a tutorial on webmonkey. What's the deal with bogus information in a tutorial. How's anybody supposed to learn from that?

Anyhow, thanks for the advice.
I still don't exactly understand what PHP is going to do for me though. I've not been able to find any good examples of how it's used.

I'm also having a problem setting up a testing server. I'm on a mac OSX and I'm using dreamweaver, what exactly is the procedure for setting up the testing server.

Thanks again.

CK

bcolflesh

1:54 pm on Sep 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Take a look at:

devshed.com/Server_Side/Administration/BuildingOnOSX/

Slade

2:01 pm on Sep 17, 2003 (gmt 0)

10+ Year Member



[us4.php.net...]

Print is a valid function for php. Look for another problem.

Make sure the site is actually processing php. Try cutting the code down to just an open php statement, a print, and a close php.

If that doesn't help, paste the error message here for us.

ckhagen

2:35 pm on Sep 17, 2003 (gmt 0)

10+ Year Member



Ok,

I thought print was valid. I used echo and it produced the same results. I'm 99.9% sure that my server has PHP. The error message I'm getting is:

Parse error: parse error in /home/missions/public_html/test/index.php on line 6

Make any sense.

I also tried it like you said (or at least I think I did what you said). I got the same results.

CK

Slade

3:20 pm on Sep 17, 2003 (gmt 0)

10+ Year Member



I copied your code as is and pasted it into a file on my personal site. It ran fine. The only thing that remotely looks wrong is the space after the function name print.

It ran fine both ways for me.

Submit a ticket with your host and ask them to look at it.

BjarneDM

8:42 pm on Sep 17, 2003 (gmt 0)

10+ Year Member



bcolflesh :
The devshed article is way out of date
- there're much never versions of all the programs
- it's definitely not an article for beginners
- it's written for Mac OS X 10.1 and several things have changed since
- you can get all of the programs in easy to install packages from [serverlogistics.com...]

ckhagen :
- php questions are much better answered in the 'PHP Server Side Scripting' forum
- Mac OS X questions will gladly be answered by me and others in the 'The Macintosh Webmaster' forum

ckhagen :
that said .,.
1) try substituting your text with something completely simple like "x"
2) get PHP to *not* parse the text-string by enclosing it in single apostrophes like this 'where\'s my cheese?'

PHP will be of great use to you in the following situations:
- you have a basic template and use the URL as the basis for piecing together various files to present to the visitor
- you need to interact with a database like MySQL
- you need to process forms on the server

ergophobe

5:15 pm on Sep 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




The only thing that remotely looks wrong is the space after the function name print.

That's just a convention to make it easier to tell function calls from comparisons in loops. Whitespace shouldn't matter.


You don't use "print" to print a line in PHP, you use the "echo" command.

print and echo are exact synonyms in PHP. print_r() and printf() however don't have echo equivalents.


Make sure the site is actually processing php


I'm 99.9% sure that my server has PHP.

You can be 100% sure since you can't get a parse error unless the site is processing PHP. These messages are generated by the PHP processor.

One thing to keep in mind: PHP generates a message for the line where it NOTICES that there is an error, which means it could be the line mentioned or any previous line. The cause of the error being higher than the line mentioned is usually that you have forgotten
- a semicolon
- to close a quote or a paren

Good luck