General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 23rd, 2003, 10:27 AM
evildan evildan is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: Madison, WI
Posts: 2 evildan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to evildan
Parse Error T_ECHO

Quote:
Parse error: parse error, unexpected T_ECHO in /Library/WebServer/Documents/clients/whg/admin/upload2.php on line 13


I've been getting this or similar errors more and more frequently. It seems whenever I use snippets of code from other sources this is my default error message.

My latest attempt is to create a simple file upload. I'm using the following code as described on php.net
Quote:
Page 1
<form enctype="multipart/form-data" action="upload2.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="30000">Send this file: <input name="userfile" type="file">
<input type="submit" value="Send File">
</form>

Page 2
$uploaddir = "/Library/WebServer/Documents/gallery/";
$uploadfile = $uploaddir. $_FILES['userfile']['name'];

echo "<pre>";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
__ echo "File is valid, and was successfully uploaded. ";
__ echo "Here's some more debugging info:<br>";
__ print_r($_FILES);
} else {
__ echo "Possible file upload attack!_ Here's some debugging info:<br>";
__ print_r($_FILES);
}
echo "</pre>";

I'm using php v. 4.3.0 and have hi-lighted line 13, which is a simple php echo command. I've also noticed with this error - it occurs even if the code has not been parsed. Meaning the condition may result to false, but because it's some kind of parse error, the page displays this error anyway.

Any thoughts?

Reply With Quote
  #2  
Old December 23rd, 2003, 10:49 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
My guess is that you're copying and pasting in line breaks. See how the line just above 13 wraps between brackets? That'll cause a parse error in a heartbeat. Try fixing that line and I'll bet this error goes away. You're right that a parse error like this will keep the script from even being executed; it's not that the error in question is a default error, but that there really are parse errors that need to be fixed.

Reply With Quote
  #3  
Old December 23rd, 2003, 02:25 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
Quote:
__ echo "File is valid, and was successfully uploaded. ";
__ echo "Here's some more debugging info:<br>";
__ print_r($_FILES);


what are the underscores?
were they in your code?
that might cause a problem too... ?

Reply With Quote
  #4  
Old December 23rd, 2003, 02:33 PM
evildan evildan is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: Madison, WI
Posts: 2 evildan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to evildan
I was actually just replying to this to let you know that it was some weird hidden characters in my code. I copied the code from a web page, pasted it into my text editor and modified it. I stripped it down to plain text and even viewed hidden characters, which did NOT reveal any of this.

It was only after posting this code here that I too saw the underscores and thought I might be missing something. I removed the spaces (as they were displayed) and everything is operating as expected.

Thanks for the quick response!

Reply With Quote
  #5  
Old December 23rd, 2003, 02:38 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
Sheesh, I didn't even notice the underscores.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Parse Error T_ECHO


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT