473,405 Members | 2,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

First script - basic question

Hi,

I created an HTML page with the following code:
<html>
<body>
<form action="everif.php" method="post">
Name: <input type="text" name="name" size="12"><br>
First name: <input type="text" name="fname" size="12">
<input type="submit" value="OK">
</form>
</body>

</html>

and everif.php contains:
<?php
$fname= $_POST['fname'];
$name= $_POST['name'];
echo("<center>Hi $fname $name</center>");
?>
When I press OK from the HTML page 1 get:
Parse error: parse error, unexpected T_VARIABLE in
/var/www/free.fr/d/c/parispain/everif.php on line 2

where line 2 is:
$fname= $_POST['fname'];
Why?

Thank you.

Jul 17 '05 #1
12 1446
> <?php
$fname= $_POST['fname'];
$name= $_POST['name'];
echo("<center>Hi $fname $name</center>");
?>
When I press OK from the HTML page 1 get:
Parse error: parse error, unexpected T_VARIABLE in
/var/www/free.fr/d/c/parispain/everif.php on line 2

where line 2 is:
$fname= $_POST['fname'];


I am not sure but first of all you should check if $_POST['fname']; is set .
so it should be somthing like :
if (isset($_POST['fname'])) $fname = $_POST['fname'];
else $fname = "";

the same for the $_POST['name']

Try that ... but then again I am not sure if it solves your problem!!!
Jul 17 '05 #2
> echo("<center>Hi $fname $name</center>");

And This is not going to echo your $fname and $name ...

Do that:
echo ("Hello".$fname." ".$name);
Jul 17 '05 #3
lo*************@yahoo.fr wrote:
(snip)
everif.php contains:
<?php
$fname= $_POST['fname'];
$name= $_POST['name'];
echo("<center>Hi $fname $name</center>");
?>

When I press OK from the HTML page 1 get:
Parse error: parse error, unexpected T_VARIABLE in
/var/www/free.fr/d/c/parispain/everif.php on line 2


Your code looks Ok to me. You don't need any brackets in the echo statement,
but it doesn't really matter.

Perhaps there's a problem with the line breaks in your PHP source. I think
PHP likes to see a carriage return and linefeed at the end of every line.
Some editors (especially on Mac systems) use carriage returns but no
linefeeds.

--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/
Jul 17 '05 #4
Angelos wrote:
echo("<center>Hi $fname $name</center>");


And This is not going to echo your $fname and $name ...


Yes it is!

--
Oli

Jul 17 '05 #5
Philip Ronan wrote:
Perhaps there's a problem with the line breaks in your PHP source. I think PHP likes to see a carriage return and linefeed at the end of every line. Some editors (especially on Mac systems) use carriage returns but no
linefeeds.


Who told you that? You can write a whole PHP script all on line without
any newlines or carriage returns if you want.

--
Oli

Jul 17 '05 #6
On Tue, 17 May 2005 09:56:07 +0000 (UTC), Angelos wrote:
echo("<center>Hi $fname $name</center>");
And This is not going to echo your $fname and $name ...


Yes it is.
Do that: echo ("Hello".$fname." ".$name);


No, no need for that when using double quotes.
--
Firefox Web Browser - Rediscover the web - http://getffox.com/
Thunderbird E-mail and Newsgroups - http://gettbird.com/
Jul 17 '05 #7
On Tue, 17 May 2005 11:12:10 +0100, Philip Ronan wrote:
<?php
$fname= $_POST['fname'];
$name= $_POST['name'];
echo("<center>Hi $fname $name</center>");
?>

When I press OK from the HTML page 1 get:
Parse error: parse error, unexpected T_VARIABLE in
/var/www/free.fr/d/c/parispain/everif.php on line 2


Your code looks Ok to me.


Me too. Did you copy and paste the code in your news post, or type it?
Your error could be from one space too many, for example after <? or $.
--
Firefox Web Browser - Rediscover the web - http://getffox.com/
Thunderbird E-mail and Newsgroups - http://gettbird.com/
Jul 17 '05 #8
Oli Filth wrote:
Philip Ronan wrote:
Perhaps there's a problem with the line breaks in your PHP source. I

think
PHP likes to see a carriage return and linefeed at the end of every

line.
Some editors (especially on Mac systems) use carriage returns but no
linefeeds.


Who told you that? You can write a whole PHP script all on line without
any newlines or carriage returns if you want.


I just seem to recall having a few parse errors of my own before I set my
text editor up to use DOS line breaks.

I can't see what else could be wrong with the OP's script.

Can you?

--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/
Jul 17 '05 #9
I cut and paste the script so I do not think additional spaces could be
the origin of the problem.
However, I *AM* using a Mac and it could be a carriage return issue...

Jul 17 '05 #10
On 17 May 2005 06:04:03 -0700, lo*************@yahoo.fr wrote:
However, I *AM* using a Mac and it could be a carriage return issue...


Yes, probably, if your server is not a Mac.
--
Firefox Web Browser - Rediscover the web - http://getffox.com/
Thunderbird E-mail and Newsgroups - http://gettbird.com/
Jul 17 '05 #11
lo*************@yahoo.fr wrote:
I cut and paste the script so I do not think additional spaces could be
the origin of the problem.
However, I *AM* using a Mac and it could be a carriage return issue...


There are lots of decent free/shareware editors that might help. Try BBEdit
and JEdit, for example.

--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/
Jul 17 '05 #12
OK,

The issue was just an uncorrect unicode space character replacing a
normal space, around an '=' sign.

Thank you very much,

Loïc

Jul 17 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Brian Madden | last post by:
Hello Everyone, This is sort of a followup to the protecting files question I asked earlier today. I would like to protect a file so that only certain users could download it from my website....
4
by: Ian Giblin | last post by:
I am an experienced C programmer, learning C++ by writinging a mathematical toolkit in the framework of a script interpreter. I am posting here to ask for advice (or references) on the object...
16
by: fernandez.dan | last post by:
Hey I'm sorry if this is not the appropriate news group for this question. I was wondering if anyone has any recommendation for embbedding a script engine in a c++ application. I want to feed my...
14
by: Sinity | last post by:
Anyone knows the method/codes to disable the clicked button after first click by using .aspx-- to prevent people to click many time when waiting for the server response. I tried to do this by...
8
by: Fabrizio Cyber | last post by:
Hi all, I want to use a .js into a visual basic project. How can I do it ? I've tried to open the script code into my project....and then ??? I see the code but I don't jnow how to make it...
5
by: Ankur | last post by:
Hi Folks, I am new for this group. I want to clarify one thing what's a basic difference between Client Side Java Script and Server Side Java Script. how we can differentiate it. Why we called...
2
by: =?Utf-8?B?RGF2aWQ=?= | last post by:
Hello I'm trying to develop a Windows service, in visual studio 2005, which executes a visual basic script. However, if the script interacts with the file system (as it has to), the script...
12
by: Marc | last post by:
Comming from JSP-HTML when I hear 'script' I think of JavaScript or perhaps VBScript. But I think in ASP.NET they mean something else? I am bit confused now. Reading a book I see the following:...
4
by: manu | last post by:
Hi, I need to parse xml files for the Blender Game Engine. ATM I am trying to get this script running in the BGE. This is my first script and I dont have much experience programming... import...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.