WebmasterLingo
Windows 2003, cPanel & DirectAdmin Unix Web Hosting

Go Back   WebmasterLingo > Programming Corner
User Name
Password

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old February 24th, 2004, 12:03 AM   #1
Steveo31
Registered User
 
Join Date: Jan 2004
Posts: 40
Steveo31 is off the scale
Send a message via AIM to Steveo31
Error

I'm learnin PHP, so be nice

This is givin me an error I can't get around... could you take a look?
PHP Code:
 <html>
<
head>
<
title>Untitled Document</title>
<
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</
head>

<
body>
<?
php

if(isset($name) && isset($address) && isset($comments)){
$name=$_POST['name'];
$address=$_POST['address'];
$comments=$_POST['comments'];
print 
"<table width=\"100%\" height=\"30%\" cellpadding=\"0\" cellspacing=\"0\">
    <tr>
        <td>
        Name:  $_GET['name']<br>
        Email:  $_GET['address']<br>
        Comments:  $_GET['comments']<br>
        </td>
    </tr>
</table>" 
or die(php_error());
}else{
    print 
"<table width=\"100%\" height=\"30%\" cellpadding=\"0\" cellspacing=\"0\">
    <tr>
        <td>
        Please fill out the form.\n
        </td>
    </tr>
</table>"
;
}
}
?>
<form action="<? $_SERVER['PHP_SELF'?> " method="post">
  <p>
    Name:&nbsp;&nbsp;<input type="text" name="name">
  </p>
  <p> 
    E-Mail:&nbsp;&nbsp;<input type="text" name="address">
  </p>
  <p>
    Comments:&nbsp;&nbsp;<textarea cols="20" rows="10" name="comments"></textarea>
  </p>
  <p>
  <input type="submit" value="Submit">
  </p>
</form>
</body>
</html> 

Error:

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in c:\program files\easyphp1-7\www\tester.php on line 17


Thanks.
Steveo31 is offline   Reply With Quote
Old February 24th, 2004, 05:05 AM   #2
ZYV
PHP addict
 
Join Date: Dec 2003
Location: Russia, Nizhny Novgorod
Posts: 71
ZYV is off the scale
Send a message via ICQ to ZYV Send a message via AIM to ZYV
Here is the correct version:

PHP Code:
 <html
<
head
<
title>Untitled Document</title
<
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
</
head

<
body
<?
php 

if(isset($name) && isset($address) && isset($comments)){ 
$name=$_POST['name']; 
$address=$_POST['address']; 
$comments=$_POST['comments']; 
print 
"<table width=\"100%\" height=\"30%\" cellpadding=\"0\" cellspacing=\"0\"> 
    <tr> 
        <td> 
        Name:  "
.$name."<br> 
        Email:  "
.$address."<br> 
        Comments:  "
.$comments."<br> 
        </td> 
    </tr> 
</table>" 
or die(php_error()); 
}else{ 

    print 
"<table width=\"100%\" height=\"30%\" cellpadding=\"0\" cellspacing=\"0\"> 
    <tr> 
        <td> 
        Please fill out the form.\n 
        </td> 
    </tr> 
</table>"



?> 

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> 
  <p> 
    Name:&nbsp;&nbsp;<input type="text" name="name"> 
  </p> 
  <p> 
    E-Mail:&nbsp;&nbsp;<input type="text" name="address"> 
  </p> 
  <p> 
    Comments:&nbsp;&nbsp;<textarea cols="20" rows="10" name="comments"></text> 
  </p> 
  <p> 
  <input type="submit" value="Submit"> 
  </p> 
</form> 
</body> 
</html> 


I didn't remember all the errors, there were lots of, but the main was

PHP Code:
 Name:  $_GET['name']<br
        
Email:  $_GET['address']<br
        
Comments:  $_GET['comments']<br


And one extra closing brace "}"

Hope that helps.
__________________
God is real, unless declared as integer
ZYV is offline   Reply With Quote
Old February 26th, 2004, 09:35 PM   #3
Steveo31
Registered User
 
Join Date: Jan 2004
Posts: 40
Steveo31 is off the scale
Send a message via AIM to Steveo31
Thanks for the help, and it makes sense, but the solution was:
PHP Code:
 <html>
<
head>
<
title>Untitled Document</title>
<
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</
head>

<
body>
<?
php

if(!empty($_POST['name']) && !empty($_POST['address']) && !empty($_POST['comments'])){
$name=$_POST['name'];
$address=$_POST['address'];
$comments=$_POST['comments'];
print 
"<table width=\"100%\" height=\"30%\" cellpadding=\"0\" cellspacing=\"0\">
    <tr>
        <td>
        Name:  $name<br>
        Email:  $address<br>
        Comments:  $comments<br>
        </td>
    </tr>
</table>" 
or die(php_error());
}else{

    print 
"<table width=\"100%\" height=\"30%\" cellpadding=\"0\" cellspacing=\"0\">
    <tr>
        <td>
        Please fill out the form.\n
        </td>
    </tr>
</table>"
;

}
?>

<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
  <p>
    Name:&nbsp;&nbsp;<input type="text" name="name">
  </p>
  <p>
    E-Mail:&nbsp;&nbsp;<input type="text" name="address">
  </p>
  <p>
    Comments:&nbsp;&nbsp;<textarea cols="20" rows="10" name="comments"></textarea></text>
  </p>
  <p>
  <input type="submit" value="Submit">
  </p>
</form>
</body>
</html> 


Thanks again

Steveo31 is offline   Reply With Quote
Old February 27th, 2004, 08:26 AM   #4
ZYV
PHP addict
 
Join Date: Dec 2003
Location: Russia, Nizhny Novgorod
Posts: 71
ZYV is off the scale
Send a message via ICQ to ZYV Send a message via AIM to ZYV
Practically the same... Cool that you worked it out.
ZYV is offline   Reply With Quote
Old February 27th, 2004, 09:45 PM   #5
Steveo31
Registered User
 
Join Date: Jan 2004
Posts: 40
Steveo31 is off the scale
Send a message via AIM to Steveo31
Well, seeing as how no one else is really posting new threads, can you explain \n and \r? I hear they are supposed to be new lines and carriage returns, but I only get spaces in the echo()'d output.
Steveo31 is offline   Reply With Quote
Old March 5th, 2004, 08:49 AM   #6
ZYV
PHP addict
 
Join Date: Dec 2003
Location: Russia, Nizhny Novgorod
Posts: 71
ZYV is off the scale
Send a message via ICQ to ZYV Send a message via AIM to ZYV
Steveo31

Quote:
can you explain \n and \r?


True, they are just new lines and carriage returns. But when you echo() them, take care to echo() "<pre>" (preformatted text) tag before, because otherwise browsers will just ignore them or consider like spaces.

Then, usually, we only use them in pair: "\r\n", most of *nix'es accept just "\n" as well, but to conform to the RFCs you should use only pairs.
ZYV is offline   Reply With Quote
Old September 1st, 2005, 03:13 AM   #7
kitty
Registered User
 
Join Date: Aug 2005
Posts: 16
kitty is on a distinguished road
u can search for php manual u will find it alot any function u want,try php.net
__________________
NewEra
web develop
kitty is offline   Reply With Quote
Old September 1st, 2005, 10:56 PM   #8
Marshall
Registered User
 
Join Date: May 2004
Posts: 70
Marshall is off the scale
Send a message via AIM to Marshall
Quote:
Originally Posted by kitty
u can search for php manual u will find it alot any function u want,try php.net

This post is over a year old so its safe to assume that ZYV's fixes worked out for him, no need to post and bring it back to the top.

edit just saw other posts - kitty are you even checking the date on the posts you and replying to? You are posting in posts a year after the last response....
__________________
Eternity-Web Hosting - PHP5 and Directadmin with Installatron Hosting

Last edited by Marshall : September 1st, 2005 at 11:02 PM.
Marshall is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -5. The time now is 04:22 PM.

JustEdge Dedicated Servers