 |
 |
 |
 |
February 24th, 2004, 12:03 AM
|
#1
|
|
Registered User
Join Date: Jan 2004
Posts: 40
|
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: <input type="text" name="name">
</p>
<p>
E-Mail: <input type="text" name="address">
</p>
<p>
Comments: <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.
|
|
|
February 24th, 2004, 05:05 AM
|
#2
|
|
PHP addict
Join Date: Dec 2003
Location: Russia, Nizhny Novgorod
Posts: 71
|
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: <input type="text" name="name">
</p>
<p>
E-Mail: <input type="text" name="address">
</p>
<p>
Comments: <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
|
|
|
February 26th, 2004, 09:35 PM
|
#3
|
|
Registered User
Join Date: Jan 2004
Posts: 40
|
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: <input type="text" name="name">
</p>
<p>
E-Mail: <input type="text" name="address">
</p>
<p>
Comments: <textarea cols="20" rows="10" name="comments"></textarea></text>
</p>
<p>
<input type="submit" value="Submit">
</p>
</form>
</body>
</html>
Thanks again

|
|
|
February 27th, 2004, 08:26 AM
|
#4
|
|
PHP addict
Join Date: Dec 2003
Location: Russia, Nizhny Novgorod
Posts: 71
|
Practically the same... Cool that you worked it out.
|
|
|
February 27th, 2004, 09:45 PM
|
#5
|
|
Registered User
Join Date: Jan 2004
Posts: 40
|
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.
|
|
|
March 5th, 2004, 08:49 AM
|
#6
|
|
PHP addict
Join Date: Dec 2003
Location: Russia, Nizhny Novgorod
Posts: 71
|
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.
|
|
|
September 1st, 2005, 03:13 AM
|
#7
|
|
Registered User
Join Date: Aug 2005
Posts: 16
|
u can search for php manual u will find it alot any function u want,try php.net
|
|
|
September 1st, 2005, 10:56 PM
|
#8
|
|
Registered User
Join Date: May 2004
Posts: 70
|
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....
Last edited by Marshall : September 1st, 2005 at 11:02 PM.
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 08:51 AM.
|
|
 |
 |
 |
 |
|