Current location: Hot Scripts Forums » General Web Coding » HTML/XHTML/XML » html input value with php variable data


html input value with php variable data

Reply
  #1 (permalink)  
Old 04-23-09, 01:09 AM
AnnPage AnnPage is offline
New Member
 
Join Date: Apr 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
html input value with php variable data

I'm having a little problem attempting to fill a html input value statement with php variable data.

$row["member_contact_info1"] contains '123 Main Street'

When the form is displayed, I can enter data '123 Main Street', the data is recorded into the database properly, the data is read from the database properly, the data is then displayed as '123' and the remaining characters are truncated.

Why is variable data being truncated after the 1st space? How can I use variable data with the html input value statement?

The example below shows variable data from an array but the result would be the same if I used ---- VALUE = $info1; where $info1='123 Main Street''

Code:
  print ("<tr>");
  print ("<td align=left>");
  print ("&nbsp;&nbsp;<b>Street 1:</b></td><td>");

  print ("<INPUT TYPE=text NAME=member_contact_info1 SIZE=41 MAXLENGTH=100 VALUE=".$row["member_contact_info1"].">");

  print ("</td>");
  print ("</tr>");
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 04-23-09, 11:33 AM
Facundo Facundo is offline
Wannabe Coder
 
Join Date: Apr 2009
Posts: 103
Thanks: 0
Thanked 0 Times in 0 Posts
Let's go to the beggining and then start making harder questions.

The easiest one:

Have you already checked that the varchar where you are inserting the street allows you to enter more than 3 characters?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 04-23-09, 12:13 PM
AnnPage AnnPage is offline
New Member
 
Join Date: Apr 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
html input value stmt using php variable data

Facundo thank you for your reply.
Maybe I didn't explain my problem properly.

The data is being recorded correctly in the database, the data is being extracted correctly from the database. The problem is displaying the data in the form field.
Even thou the variable (info1) contains '123 Main Street' the form field only displays '123' instead of '123 Main Street'.
We can forget the database entirely, if I store data into a variable i.e. $info1='123 Main Street''; and then feed $info1 into the value= statement I still only receive '123' in the form field.

Should the html form value statement correctly display a php variable?

Thanks,
Ann
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 04-23-09, 12:22 PM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
Quote:
Originally Posted by AnnPage View Post
I'm having a little problem attempting to fill a html input value statement with php variable data.

$row["member_contact_info1"] contains '123 Main Street'

When the form is displayed, I can enter data '123 Main Street', the data is recorded into the database properly, the data is read from the database properly, the data is then displayed as '123' and the remaining characters are truncated.

Why is variable data being truncated after the 1st space? How can I use variable data with the html input value statement?

The example below shows variable data from an array but the result would be the same if I used ---- VALUE = $info1; where $info1='123 Main Street''

Code:
  print ("<tr>");
  print ("<td align=left>");
  print ("&nbsp;&nbsp;<b>Street 1:</b></td><td>");

  print ("<INPUT TYPE=text NAME=member_contact_info1 SIZE=41 MAXLENGTH=100 VALUE=".$row["member_contact_info1"].">");

  print ("</td>");
  print ("</tr>");
The reason you are having this problem is because the input elements follow strict rules.
When a variable isn't specifically defined as string then the input element will stop displaying the data after the first space.
In order to correct this problem, you have to quote the PHP variable in the input element.
PHP Code:

  print ("<INPUT TYPE=text NAME=member_contact_info1 SIZE=41 MAXLENGTH=100 VALUE='".$row["member_contact_info1"]."'>"); 

__________________
Jerry Broughton
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 04-23-09, 12:46 PM
AnnPage AnnPage is offline
New Member
 
Join Date: Apr 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Trophee html input value stmt using php variable data

job0107, I can't begin to thank you enough. I didn't know where the problem was, it took a couple of days just to track it down to this statement. I've learned something I'll never forget and for that I am grateful. I owe you a pizza, Thanks!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 04-23-09, 01:18 PM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
Your welcome. Glad I could help.
__________________
Jerry Broughton
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to referene perticuler xml data in php? method PHP 6 02-21-07 11:00 PM
Classified Ads skipper23 Perl 3 11-22-05 03:22 AM
Value from HTML drop down menu into php variable? flososic PHP 5 06-11-05 06:10 AM
Php Form + mysql + display data sent needed TheRaider Script Requests 3 10-07-04 02:30 AM
Classified Ads skipper23 Perl 2 12-30-03 04:43 AM


All times are GMT -5. The time now is 01:29 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.