| mc2k2k |
|
NetHosted Customer
Joined: 06 Jan 2007 Posts: 4
|
Posted: 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 |
|
| petethegeek |
|
NetHosted Customer

Joined: 14 Feb 2005 Posts: 196 Location: Worcester
|
Posted: 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 |
|
| boughtonp |
|
NetHosted Customer
Joined: 18 Jul 2005 Posts: 130 Location: South Croydon
|
Posted: 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 |
|
| petethegeek |
|
NetHosted Customer

Joined: 14 Feb 2005 Posts: 196 Location: Worcester
|
Posted: 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 |
|
| mc2k2k |
|
NetHosted Customer
Joined: 06 Jan 2007 Posts: 4
|
Posted: Thu Mar 08, 2007 9:41 am Post subject: |
| |
Thanks guys, have sorted it out now!!
Mitch |
|
| Back to top |
|
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
|
| |