GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 03-Apr-2004, 01:04
pepee's Avatar
pepee pepee is offline
New Member
 
Join Date: Apr 2004
Posts: 11
pepee is on a distinguished road
Question

echo <<< doesn't work...


Hey everybody ,

It's my first week of PHP/MySQL and i am working on a uploader/editor of DB online. While reading around to solve the never ending mysteries, i found an echo function written:
PHP Code:

echo <<< FOO 
     <form action="upload.php" method="post" enctype="multipart/form-data"> 
     <input type=file name="File" size="20"><br /> 
     <input type=submit name="Upload" value="Upload"> 
     </form> 
FOO; 


instead of:

PHP Code:

echo "
     <form action=\"upload.php\" method=\"post\" enctype=\"multipart/form-data\"> 
     <input type=file name=\"File\" size=\"20\"><br /> 
     <input type=submit name=\"Upload\" value=\"Upload\"> 
     </form>"; 


I guess the <<< is to avoid putting '\' every time there is a ' " '
Since my php file has now more than 400 lines, it would be very time saving to use echo<<< instead of echo ""; However. This doesn't work for me for some reason. When i try it, i get:
Quote:
Parse error: parse error, unexpected T_SL, expecting ',' or ';' in D:\WEB\TestSite\TMPukzjrvkilv.php on line 9

Can somebody please tell me how to fix that. Is it from the php version i am using, or is it from the configuration files?

Apache/2.0.48 (Win32) PHP/4.3.4 Server at localhost Port 80

Thank You
  #2  
Old 03-Apr-2004, 02:24
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Hello pepee,

I was just glancing through the "What's new in PHP 4.3.5" and didn't notice a bugfix with the HEREDOC syntax in version 4.3.4. Maybe you could go through the list thoroughly or check the bug list.

However, I also use 4.3.4 on my local machine (win32) and just ran your code and it worked fine.

Perhaps it's an issue with other code inside your script? Was this all the code in the PHP page when you tested it?
  #3  
Old 03-Apr-2004, 02:43
pepee's Avatar
pepee pepee is offline
New Member
 
Join Date: Apr 2004
Posts: 11
pepee is on a distinguished road
Yes, it was the only thing:
PHP Code:

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

<? 
echo <<< FOO 
     <form action="upload.php" method="post" enctype="multipart/form-data"> 
     <input type=file name="File" size="20"><br /> 
     <input type=submit name="Upload" value="Upload"> 
     </form> 
FOO; 
?> 
</body>
</html> 

I am working on DreamweaverMX, which recognizes the colors of php, but it doesn't in this case...
  #4  
Old 03-Apr-2004, 02:46
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Instead of using DW, can you try creating that file with Notepad and saving it (replacing the DW version) and view the page again? Just to rule out DW as the culprit.
  #5  
Old 03-Apr-2004, 02:51
pepee's Avatar
pepee pepee is offline
New Member
 
Join Date: Apr 2004
Posts: 11
pepee is on a distinguished road
made a new file.txt
put the code,
saved it,
renamed it,
ran it.
same thing happens.
(hehe, like a poem LOL)
  #6  
Old 03-Apr-2004, 02:59
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
I don't know pepee, like I said, the code example you pasted worked well on my test server.

You could try a few other minor things at least until you get this working:
  • don't use short tags when starting your PHP code.
  • Replace <<< FOO with <<<FOO.
  • Make sure DW is NOT allowed to modify/correct files with .php extensions.

This may be unrelated to the issue but it will not hurt to rule it out as well. Don't use the preview in browser via DW. View the page from http://localhost ?
  #7  
Old 03-Apr-2004, 03:02
gardolas's Avatar
gardolas gardolas is offline
Awaiting Email Confirmation
 
Join Date: Jan 2004
Location: Devon
Posts: 11
gardolas is on a distinguished road
very strange just copied the code straight from here and got the same error yet when I copied the code from the original script it worked, however both are the same!

used
PHP Code:

echo <<< FOO
     <form action="upload.php" method="post" enctype="multipart/form-data">
     <input type=file name="File" size="20"><br />
     <input type=submit name="Upload" value="Upload">
     </form>
FOO; 



Very confused!
  #8  
Old 03-Apr-2004, 03:06
pepee's Avatar
pepee pepee is offline
New Member
 
Join Date: Apr 2004
Posts: 11
pepee is on a distinguished road
JDS:
OK. I will stick to those rules. I only don't understand the third bulletpoint.

gardolas:
haha, tanx man, that made things easier
  #9  
Old 03-Apr-2004, 03:19
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
In DW, click Edit -> Preferences.

Select Code Rewriting under Categories, in the box next to Never Rewrite Code (on the right), add .php
  #10  
Old 03-Apr-2004, 03:22
pepee's Avatar
pepee pepee is offline
New Member
 
Join Date: Apr 2004
Posts: 11
pepee is on a distinguished road
It is already set so. I guess this is the default. But tanx, i know what this is now.
 
 

Recent GIDBlogFirst week of IA training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in ukrspp21 MySQL / PHP Forum 31 04-Jul-2006 21:41
Why doesnt my form work correctly? rhino1616 Web Design Forum 2 06-Nov-2003 17:21
How do web redirection scripts work? rhino1616 Web Design Forum 9 27-Oct-2003 09:47
Add a tool to a yet written code-help would be great! norok MySQL / PHP Forum 2 14-Jul-2003 10:30
A very good sitemap script jrobbio MySQL / PHP Forum 3 03-Mar-2003 01:07

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 15:12.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.