Forum Moderators: mack
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>
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
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
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.
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
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
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