magmazing Posted March 25, 2006 Share Posted March 25, 2006 The issue I'm running into is sort of a mixture of a html form/php/mysql problem.I'm trying to set up a "members" html form in php that will bring up each membership's info so that they can update/change addresses, passwords etc.Here's the problem (I'll give examples of what's working and what's not)In my form I've got a text input box for someone's first Name and am accessing my database to make the specific members first name as the default value as shown below:[i]echo "<input name=FirstName type=text size=25 maxlength=25 value=" . $row['first_name'] . "> \n" ;[/i]The output of that is let's say "Steve". Everything works fine,But when I try to retrieve Steve's address (let's call it "123 Broadway Avenue") from my database to be the default value in the input box as coded below:[i]echo "<input name=Address type=text size=35 maxlength=100 value=" . $row['address'] . ">" . $row['address'] . "\n" ;[/i]The output on the form comes out as just "123"... The "Broadway Avenue" is missing.Now I've tested simply echoing $row['address] by itself and the entire address is outputted. I've also changed the form code from "input" to "textarea" and it comes back with the full address. Why won't the whole address show up on the "input" box? Does it not like spaces? I'm a bit of a rookie at working with php, databases and forms, but have managed to get most things to work, but this has confused me a bit.Any advice if you can decifer what I'm talking about would be fantastic. Thanks. Quote Link to comment Share on other sites More sharing options...
shocker-z Posted March 25, 2006 Share Posted March 25, 2006 I think it's because of the spaces you will be using as your not using value="123 Broadway Avenue" your echoing as value=123 Broadway Avenuetherefore 'Broadway' and 'Avenue' are being looked at as an eliment of the input box not the actual valueTry this code mate[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]echo '<input name=Address type=text size=35 maxlength=100 value="' . $row['address'] . '">' . $row['address'] . "\n" ;[/quote]see how i've used ' as the main string.. this lets us use " without having to put \" and then just before the . we have " to be the first of " in value="" and then ' to close the string and echo the variable..See how that goes :) Quote Link to comment Share on other sites More sharing options...
magmazing Posted March 25, 2006 Author Share Posted March 25, 2006 [!--quoteo(post=358172:date=Mar 24 2006, 11:55 PM:name=shocker-z)--][div class=\'quotetop\']QUOTE(shocker-z @ Mar 24 2006, 11:55 PM) [snapback]358172[/snapback][/div][div class=\'quotemain\'][!--quotec--]I think it's because of the spaces you will be using as your not using value="123 Broadway Avenue" your echoing as value=123 Broadway Avenuetherefore 'Broadway' and 'Avenue' are being looked at as an eliment of the input box not the actual valueTry this code matesee how i've used ' as the main string.. this lets us use " without having to put \" and then just before the . we have " to be the first of " in value="" and then ' to close the string and echo the variable..See how that goes :)[/quote]Nice! It worked. Thanks so much! The wonders that are the use of single quotes and double quotation marks. I've been trying to learn this stuff without the help of books and just by literally trial and error and was getting by okay and then that issue popped up and I was like, "what the hell am I doing wrong?" So yeah, I've learned something today. If you were to see the rats nest that is the rest of the coding of what I'm doing, it's amazing how I got anything to work at all.Thanks again. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.