Client Support Community Server Status Contact Us Client Login
Email Hosting Website Hosting Reseller Hosting VPS Hosting Dedicated Servers

    Join our Community      Check your private messages       Profile       Search       FAQ       Memberlist       Log in


php + mysql problem

 
Post new topic   Reply to topic    NetHosted Community Index -> Web Design
mc2k2k Reply with quote
 NetHosted Customer

 

 Joined: 06 Jan 2007
 Posts: 4
 

PostPosted: Wed Mar 07, 2007 5:33 pm    Post subject: php + mysql problem
 
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
Back to top
View user's profile Send private message
petethegeek Reply with quote
 NetHosted Customer

 

 Joined: 14 Feb 2005
 Posts: 196
 Location: Worcester

PostPosted: Wed Mar 07, 2007 8:07 pm    Post subject:
 
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
Back to top
View user's profile Send private message Visit poster's website
boughtonp Reply with quote
 NetHosted Customer

 

 Joined: 18 Jul 2005
 Posts: 130
 Location: South Croydon

PostPosted: Wed Mar 07, 2007 11:33 pm    Post subject:
 
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
Back to top
View user's profile Send private message Visit poster's website
petethegeek Reply with quote
 NetHosted Customer

 

 Joined: 14 Feb 2005
 Posts: 196
 Location: Worcester

PostPosted: Thu Mar 08, 2007 6:52 am    Post subject:
 
boughtonp wrote:
And since you're using PHP, you'll want to escape the quotes, with \ before them:


<nit probability="low">Unless they are in a heredoc .</nit>

Regards,

Pete

_________________
"I have made this letter long, only because I lacked the time to make it short." - Blaise Pascal 1657
Back to top
View user's profile Send private message Visit poster's website
mc2k2k Reply with quote
 NetHosted Customer

 

 Joined: 06 Jan 2007
 Posts: 4
 

PostPosted: Thu Mar 08, 2007 9:41 am    Post subject:
 
Thanks guys, have sorted it out now!!

Mitch
Back to top
View user's profile Send private message
Post new topic   Reply to topic    NetHosted Community Index -> Web Design
Page 1 of 1

User Permissions
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum

 
Jump to: