[SOLVED] Parse error-Need Help!

This is a discussion on "[SOLVED] Parse error-Need Help!" within the PHP Forum section. This forum, and the thread "[SOLVED] Parse error-Need Help! are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Dec 17th, 2007, 18:07
Up'n'Coming Member
Join Date: Apr 2007
Location: Canada
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
[SOLVED] Parse error-Need Help!

Hi fellows!

I am using a form in my update profile page and getting an error like--
Parse error: syntax error, unexpected '<' in /home/dbanglad/public_html/111/1profile.php on line 8

with the following code
PHP: Select all

<?php
require "check.php";
// If member has logged in then below script will be execuated. 
// let us collect all data of the member 
$row=mysql_fetch_object(mysql_query("select * from tbl_login where userid='$_SESSION[userid]'"));
<
form action='update-profileck.phpmethod='post'/>
<
input type=hidden name=todo value=update-profile>     
<
fieldset>
<
legend>Update Profile</legend>
<
label for="LastName">Last Name</label>
<
input id="LastName" name="LastName" value='$row->Last_Name' type="text"/><br/>
 
</
fieldset>
</
form>
echo 
"<br/>Welcome $_SESSION[userid] <br/><br/>Click &nbsp;<a href=logout.php>here to logout</a> &nbsp; | &nbsp; <a href=change-password.php>Change Password</a>| &nbsp; <br/>";
?>
Any idea or help would be much appreciated. It is not all the form though it just a part if any one wonder. pls explain if you have any answer cauze I am a novice with all this code.
Reply With Quote

  #2 (permalink)  
Old Dec 17th, 2007, 18:21
alexgeek's Avatar
Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,771
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: Parse error-Need Help!

You need to close your PHP tags
PHP: Select all


<?php
require "check.php";
// If member has logged in then below script will be execuated. 
// let us collect all data of the member 
$row=mysql_fetch_object(mysql_query("select * from tbl_login where userid='$_SESSION[userid]'"));
?>
<form action='update-profileck.php' method='post'/>
<input type=hidden name=todo value=update-profile>     
<fieldset>
<legend>Update Profile</legend>
<label for="LastName">Last Name</label>
<input id="LastName" name="LastName" value='$row->Last_Name' type="text"/><br/>
 
</fieldset>
</form>
<?php echo "<br/>Welcome $_SESSION[userid] <br/><br/>Click &nbsp;<a href=logout.php>here to logout</a> &nbsp; | &nbsp; <a href=change-password.php>Change Password</a>| &nbsp; <br/>";
?>
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
  #3 (permalink)  
Old Dec 17th, 2007, 22:24
Up'n'Coming Member
Join Date: Apr 2007
Location: Canada
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Parse error-Need Help!

Thanks for your reply. I did close the php at the end of the form. I had to do that because I use input value as 'row->Last_Name' (for example) to retrieve data from my MySql table. If I close it before the form it does not show the data that I am retrieving in to the form.
Reply With Quote
  #4 (permalink)  
Old Dec 17th, 2007, 22:34
alexgeek's Avatar
Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,771
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: Parse error-Need Help!

Do this then
PHP: Select all


<?php
require "check.php";
// If member has logged in then below script will be execuated. 
// let us collect all data of the member 
$row=mysql_fetch_object(mysql_query("select * from tbl_login where userid='$_SESSION[userid]'"));
?>
<form action='update-profileck.php' method='post'/>
<input type=hidden name=todo value=update-profile>     
<fieldset>
<legend>Update Profile</legend>
<label for="LastName">Last Name</label>
<input id="LastName" name="LastName" value='<?php echo $row->Last_Name?>' type="text"/><br/>
 
</fieldset>
</form>
<?php echo "<br/>Welcome $_SESSION[userid] <br/><br/>Click &nbsp;<a href=logout.php>here to logout</a> &nbsp; | &nbsp; <a href=change-password.php>Change Password</a>| &nbsp; <br/>";
?>
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
  #5 (permalink)  
Old Dec 17th, 2007, 22:41
Up'n'Coming Member
Join Date: Jun 2007
Location: Birmingham, UK
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Parse error-Need Help!

Hi dhossai,

I think alexgeek just missed one PHP variable in the HTML form.
The correct version should look like this


PHP: Select all

<?php
require "check.php";
// If member has logged in then below script will be execuated. 
// let us collect all data of the member 
$row=mysql_fetch_object(mysql_query("select * from tbl_login where userid='$_SESSION[userid]'"));
?>
<form action='update-profileck.php' method='post'/>
<input type=hidden name=todo value=update-profile>     
<fieldset>
<legend>Update Profile</legend>
<label for="LastName">Last Name</label>
<input id="LastName" name="LastName" value="<?php echo $row->Last_Name ?>" type="text"/><br/>
 
</fieldset>
</form>
<?php echo "<br/>Welcome $_SESSION[userid] <br/><br/>Click &nbsp;<a href=logout.php>here to logout</a> &nbsp; | &nbsp; <a href=change-password.php>Change Password</a>| &nbsp; <br/>";
?>
One important thing when programming PHP is that all the PHP code needs to be enclosed in the <?php ?> tags, while all the HTML code must be placed outside those tags. When outside the tags, you cannot use the PHP variables, so you have to open and close the PHP tags, whenever you want to produce dynamic content.

See how, in the last line, the echo command is used to generate HTML. This is how HTML is generated when inside the <?php ?> tags.

Btw also note that I've replaced the single quotes around the value field with double quotes.
Reply With Quote
  #6 (permalink)  
Old Dec 17th, 2007, 22:51
alexgeek's Avatar
Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,771
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: Parse error-Need Help!

I kinda already posted that mate.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
  #7 (permalink)  
Old Dec 17th, 2007, 23:21
Up'n'Coming Member
Join Date: Apr 2007
Location: Canada
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Parse error-Need Help!

Thanks guys. It works. Alex made mistake by putting ";" at the end which was
PHP: Select all

'<?php echo $row->Last_Name?>'
But hschmitz corrected it.
Thanks to all again.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Getting the &quot;Microsoft JET Database Engine error '80040e14'&quot; error. VegaLA Classic ASP 3 Jan 26th, 2008 00:12
[SOLVED] parse error, unexpected T_EXIT in php mail script Posie PHP Forum 8 Dec 13th, 2007 14:21
[SOLVED] SQL Error [mysql4] Daniel Databases 3 Sep 23rd, 2007 15:29
What is a Parse Error? rubyfruit Starting Out 1 Jul 5th, 2007 20:40
Parse Error Maverick25r PHP Forum 4 Sep 15th, 2006 16:55


All times are GMT. The time now is 22:23.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43