homepage Welcome to WebmasterWorld Guest from 54.161.240.10
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Populated a form from a table
why should spaces cause a problem
UK_matrix




msg:1263925
 12:50 pm on Mar 6, 2002 (gmt 0)

Hi,

I'm filling a form from a MySQL table using PHP. Everyone is fine except for the instances where the field has a space (eg. the address).
If the value on the table is :
1 Main Street
all I get in the form field is :
1

the code I'm using is:
<input type=Text name=address1 SIZE=30 VALUE=$myrow[address1]>

nothing unusual there is there ?

I hope somebody can help 'cos there's much scratching of heads here :)

 

sugarkane




msg:1263926
 1:04 pm on Mar 6, 2002 (gmt 0)

The problem's in the HTML - if you put quotes around the value it should be fine.

UK_matrix




msg:1263927
 1:15 pm on Mar 6, 2002 (gmt 0)

Nope. That doesn't work either, and it's not an HTML problem because the table is within the <?php tag

sugarkane




msg:1263928
 1:20 pm on Mar 6, 2002 (gmt 0)

Well, if $myrow[address1] is 1 Main Street, you end up with this HTML:

<input type=Text name=address1 SIZE=30 VALUE=1 Main Street>

The browser only sees the '1' as the value - the spaces make it look to the browser as if Main and Street are extra attributes to the input tag, and as it doesn't recognise them, it just ignores them :)

Changing the code to:
<input type=Text name=address1 SIZE=30 VALUE="$myrow[address1]">

will result in

<input type=Text name=address1 SIZE=30 VALUE="1 Main Street">

being generated, and all will be well...

UK_matrix




msg:1263929
 1:28 pm on Mar 6, 2002 (gmt 0)

aah! I'd forgotten I need to place a / before the quotes to let PHP know the quotes are valid.

Thanks a lot sugarkane.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved