473,320 Members | 1,988 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,320 software developers and data experts.

Trouble fixing parse error, unexpected T_IF error

Howdy -
In setting up a registration form, I'd like to keep any correct entries on the form (make them sticky).

The Registration Form is "included" and has the the following structure:

Expand|Select|Wrap|Line Numbers
  1. <body>
  2.  <?php
  3.     echo "    <p>
  4.  
  5.     <form action=$_SERVER[PHP_SELF] method='POST'>
  6.        <table width='95%' border='0' cellspacing='0' cellpadding='2'> 
  7.  
  8.          <tr><td></td><td>Please fill in all information.</td></tr>
  9.  
  10.           <tr><td align='right'><b>First Name:</b></td>
  11.       <td><input type='text' name='FirstName' size='35' 
  12.                 maxlength='35'  value="if (isset($_POST['FirstName']))
  13.                      {echo $_POST['FirstName']}; "></td></tr>
  14.  
  15.  
  16.           </table>
  17.         <input type='hidden' name='submitted' value='yes'>
  18.       </form>
  19.   </p> 
  20.  ?>
  21. </body>
  22.  
This generates the following error message:
parse error, unexpected T_IF, expecting ',' or ';' in /html/RegistrationForm1.php on line 12

How does one punctuate the "if (isset...) to provide the indicated ", or ;" the compiler is looking for?
Would appreciate any help or suggestions.

Thanks
Nov 11 '08 #1
6 5343
Dormilich
8,658 Expert Mod 8TB
you missed the ; in the execution block (line 34) and put it outside the brackets (just swap } and ;)
[PHP]if (...)
{
echo $var; // semicolon here
} // not here[/PHP]
note: a proper indentation style may increase readability a lot. you may consider to separate markup and processing by first evaluating all expressions and insert the results in your markup.

regards
Nov 11 '08 #2
Banfa
9,065 Expert Mod 8TB
Ciaroscuro,

your code will be better formated and easier for our experts to read if you put [code]...[/code] tags round it like I have done for you now.

Please read our posting guidelines

Banfa
Administrator
Nov 11 '08 #3
Dormilich & Banfa -

Thank you for your responses. I tried changing the position of the semi-colon but that didn't change the error message. I ended up converting from a PHP echo form to a staight HTML form with <?php ...?> phrases for the

Expand|Select|Wrap|Line Numbers
  1. <form action="<?php $_SERVER[PHP_SELF];?>" method="POST">
and

Expand|Select|Wrap|Line Numbers
  1. <tr><td align='right'><b>First Name:</b></td>
  2.     <td><input type='text' name='FirstName' size='35'
  3.           maxlength='35' value="<?php if(isset($_POST['FirstName']))
  4.       echo $_POST['FirstName'];?>"/></td></tr>
to get the sticky Value attribute to work.

Still haven't figured out why the <?php echo format didn't work, but this other approach does, so I'm making forward progress again. Thanks.
Nov 12 '08 #4
Markus
6,050 Expert 4TB
Dormilich & Banfa -

Thank you for your responses. I tried changing the position of the semi-colon but that didn't change the error message. I ended up converting from a PHP echo form to a staight HTML form with <?php ...?> phrases for the

Expand|Select|Wrap|Line Numbers
  1. <form action="<?php $_SERVER[PHP_SELF];?>" method="POST">
and

Expand|Select|Wrap|Line Numbers
  1. <tr><td align='right'><b>First Name:</b></td>
  2.     <td><input type='text' name='FirstName' size='35'
  3.           maxlength='35' value="<?php if(isset($_POST['FirstName']))
  4.       echo $_POST['FirstName'];?>"/></td></tr>
to get the sticky Value attribute to work.

Still haven't figured out why the <?php echo format didn't work, but this other approach does, so I'm making forward progress again. Thanks.
Ciaroscuro, please pay attention to post No.3 - it makes your post a lot easier to read for our experts if you use code tags.

Moderator.
Nov 12 '08 #5
Dormilich
8,658 Expert Mod 8TB
I tried changing the position of the semi-colon but that didn't change the error message.
checked your code snippet (with subethaedit using php) and I didn't get a parser error. judging from that, the code should be running fine.

regards

note: could verify the error message for the original code (just if you wonder...)
Nov 12 '08 #6
Markus
6,050 Expert 4TB
You can't have an IF statement inside and echo statement. Won't work. Create a function that does your IF checks and then RETURNs a value.

Expand|Select|Wrap|Line Numbers
  1. value=" . some_function() . "
Nov 12 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: D. Alvarado | last post by:
Hello, I am running PHP 4. I have this simple class, class CTable { var $m_name; var $m_primary_key_col_name; } then I have a function that takes, as argument, an instance of this class
3
by: Marten van Urk | last post by:
I got the following error in my page Parse error: parse error, unexpected T_ELSE in line 25 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Club</title>...
6
by: Ehartwig | last post by:
I recently created a script for user verification, solved my emailing issues, and then re-created the script in order to work well with the new PHP 5 that I installed on my server. After...
8
by: Wescotte | last post by:
The error message Parse error: syntax error, unexpected $end in FILE on line X is one I run into frequently and I know the cause is I missed an ending quote. Is there an easy way to determine...
1
by: soidariti | last post by:
database error - parse error, unexpected $, expecting kEND AddUserAuthorisationToUsers.rb migration file 1. class AddUserAuthorisationToUsers < ActiveRecord::Migration 2. def self.up ...
2
by: Sianaba | last post by:
I am getting help from a website to fix my malware etc problem.... i was instructed to run a Kaspersky scan and now when i try to get to my specific forum i get this come up instead: Parse error:...
7
by: keley | last post by:
I am trying to use a script to send a list of items from a database. The code is listed below. I get an unexpected T_IF error on the second $mailer->Body line (line 55). If I comment out the 9...
5
praclarush
by: praclarush | last post by:
I've just started php, and this is a class assignment, but my question is I’m getting this error PHP Parse error: syntax error, unexpected T_IF, expecting T_VARIABLE or '$' in...
2
by: Lawrence Krubner | last post by:
Imagine a template system that works by getting a file, as a string, and then putting it through eval(), something like this: $formAsString = $controller->command("readFileAndReturnString",...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.