These forums are now archived.


Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: php + mysql problem
PostPosted: Wed Mar 07, 2007 6:33 pm 
Offline
NetHosted Customer

Joined: Sun Jan 07, 2007 12:20 am
Posts: 4
Hello,

I've got a php script which will pull data from a mysql database. This works fine but when I try to populate a html input box with the data not all the data is displayed, e.g. for the name: John Smith, will only display John in the textbox (anything after a space is not shown), does anyone know the reason for it doing that?

The code used to ouput the data is simply just (in between php):

<input name=first_name size=20 value=$new1>

Hope someone can help,Cheers,

Mitch


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Mar 07, 2007 9:07 pm 
Offline
NetHosted Customer
User avatar

Joined: Mon Feb 14, 2005 12:24 pm
Posts: 218
Location: Worcester
Mitch,

You'll need to put quotes round the variable in the <input> tag. (Escaping if necessary.)

Regards,

Pete

_________________
"I have made this letter long, only because I lacked the time to make it short." - Blaise Pascal 1657


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Mar 08, 2007 12:33 am 
Offline
NetHosted Customer

Joined: Mon Jul 18, 2005 6:34 pm
Posts: 159
Location: South Croydon
And since you're using PHP, you'll want to escape the quotes, with \ before them:
echo "<input name=\"first_name\" size=\"20\" value=\"$new1\"/>";

Alternatively, you can switch to singles quotes for the PHP bit, and then don't need to scape the HTML quotes:
echo '<input name="first_name" size="20" value="'.$new1.'"/>';

_________________
Peter Boughton


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Mar 08, 2007 7:52 am 
Offline
NetHosted Customer
User avatar

Joined: Mon Feb 14, 2005 12:24 pm
Posts: 218
Location: Worcester

_________________
"I have made this letter long, only because I lacked the time to make it short." - Blaise Pascal 1657


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Mar 08, 2007 10:41 am 
Offline
NetHosted Customer

Joined: Sun Jan 07, 2007 12:20 am
Posts: 4


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 17 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: