Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

space problem

AgentSaenzAgentSaenz Posts: 8Member
When I want to display info from a table, I have a problem that creeps up when I have space.

my code is

while ( $row = mysql_fetch_array($result) )
{
$fname = $row['FNAME']; $lname = row['LNAME'];
$email=$row['EMAILADDR']; $addr = $row['STADDR'];
$phone = $row['PHONE'];
}

and then

echo('*First Name ');echo('
');
echo('*Last Name ');echo('
');
echo('*Email Address ');echo('
');
echo('*Street Address ');echo('
');
echo('*Phone Number ');

But when I use these input boxes to display, as soon as it hits a space, the rest is truncated. Like if the address is '409 main st'. In the database, the field contains '409 main st' and even if I use the echo(), '409 main st' appears. but if I use these input boxes, all that apears is '409'.

Any suggestions on how to handle this?

Comments

  • tradmtradm Posts: 49Member
    : When I want to display info from a table, I have a problem that
    : creeps up when I have space.
    :
    : my code is
    :
    : while ( $row = mysql_fetch_array($result) )
    : {
    : $fname = $row['FNAME']; $lname = row['LNAME'];
    : $email=$row['EMAILADDR']; $addr = $row['STADDR'];
    : $phone = $row['PHONE'];
    : }
    :
    : and then
    :
    : echo('*First Name ');echo('
    ');
    : echo('*Last Name ');echo('
    ');
    : echo('*Email Address ');echo('
    ');
    : echo('*Street Address ');echo('
    ');
    : echo('*Phone Number ');
    :
    : But when I use these input boxes to display, as soon as it hits a
    : space, the rest is truncated. Like if the address is '409 main st'.
    : In the database, the field contains '409 main st' and even if I use
    : the echo(), '409 main st' appears. but if I use these input boxes,
    : all that apears is '409'.
    :
    : Any suggestions on how to handle this?
    :

    I hate the spam on the board too!

    Hie,

    [b]This is the reasion why the code is going hay wire![/b]

    Lets examine this snippet from your code...

    [code]echo('*First Name ');echo('
    ');[/code]

    assume that $fname = 'Funny Name with Spaces' then

    [code]echo('*First Name ');[/code] will produce [color=Red]>[/color] no quotes!

    Now if you combine the outputs you get [color=Green]*First Name input type=text maxlength=50 name=fname value=Some Name with Spaces>[/color] and if your HTML is good you will agree with me that the [italic]value property of the input tag is [b]Some[/b][/italic] and the web broswer will treat Name with spaces as properties of the input tag (I guess). This is why anything after the first space does not show. Hope it make sense...


    [b]How to correct it.[/b]

    Method 1:

    You can use this syntax:
    [code]echo("*Street Address
    ");[/code]

    or

    [code]echo("*Street Address
    ");[/code]

    Method 2:

    You can output ur html code from php by escaping
    consider the following code

    [code][color=Purple]<?php
    $fname = 'SomeThing';
    //and the rest of ur php code
    ...

    //Below this closing PHP tag u can put ur HTML code without the echo statement
    //U can use echo however if u want to display ur PHP variable within HTML
    ?>[/color]
    [color=Blue]
    Some Title

    My PHP variable <?php echo $fname; ?>

    and the rest of your HTML tags can go here. Its smarter YA?

    [/color[color=Purple]]<?php
    //Optionally You may want to have another PHP region here
    ?>[/color] [color=Blue]And HTML region here [/color]
    [color=Purple]<?php
    //And PHP here and so forth...
    ?>[/color][/code]


    Hope this helps.


  • AgentSaenzAgentSaenz Posts: 8Member
    : : When I want to display info from a table, I have a problem that
    : : creeps up when I have space.
    : :
    : : my code is
    : :
    : : while ( $row = mysql_fetch_array($result) )
    : : {
    : : $fname = $row['FNAME']; $lname = row['LNAME'];
    : : $email=$row['EMAILADDR']; $addr = $row['STADDR'];
    : : $phone = $row['PHONE'];
    : : }
    : :
    : : and then
    : :
    : : echo('*First Name ');echo('
    ');
    : : echo('*Last Name ');echo('
    ');
    : : echo('*Email Address ');echo('
    ');
    : : echo('*Street Address ');echo('
    ');
    : : echo('*Phone Number ');
    : :
    : : But when I use these input boxes to display, as soon as it hits a
    : : space, the rest is truncated. Like if the address is '409 main st'.
    : : In the database, the field contains '409 main st' and even if I use
    : : the echo(), '409 main st' appears. but if I use these input boxes,
    : : all that apears is '409'.
    : :
    : : Any suggestions on how to handle this?
    : :
    :
    : I hate the spam on the board too!
    :
    : Hie,
    :
    : [b]This is the reasion why the code is going hay wire![/b]
    :
    : Lets examine this snippet from your code...
    :
    : [code]: echo('*First Name ');echo('
    ');[/code]:
    :
    : assume that $fname = 'Funny Name with Spaces' then
    :
    : [code]: echo('*First Name ');[/code]: will produce [color=Red]>[/color] no quotes!
    :
    : Now if you combine the outputs you get [color=Green]*First Name
    : input type=text maxlength=50 name=fname value=Some Name with
    : Spaces>[/color] and if your HTML is good you will agree with me that
    : the [italic]value property of the input tag is [b]Some[/b][/italic]
    : and the web broswer will treat Name with spaces as properties of the
    : input tag (I guess). This is why anything after the first space
    : does not show. Hope it make sense...
    :
    :
    : [b]How to correct it.[/b]
    :
    : Method 1:
    :
    : You can use this syntax:
    : [code]: echo("*Street Address
    ");[/code]:
    :
    : or
    :
    : [code]: echo("*Street Address
    ");[/code]:
    :
    : Method 2:
    :
    : You can output ur html code from php by escaping
    : consider the following code
    :
    : [code]: [color=Purple]<?php
    : $fname = 'SomeThing';
    : //and the rest of ur php code
    : ...
    :
    : //Below this closing PHP tag u can put ur HTML code without the echo statement
    : //U can use echo however if u want to display ur PHP variable within HTML
    : ?>[/color]
    : [color=Blue]
    : Some Title
    :
    :

    My PHP variable <?php echo $fname; ?>
    :
    : and the rest of your HTML tags can go here. Its smarter YA?
    :
    : [/color[color=Purple]]<?php
    : //Optionally You may want to have another PHP region here
    : ?>[/color] [color=Blue]And HTML region here [/color]
    : [color=Purple]<?php
    : //And PHP here and so forth...
    : ?>[/color][/code]:
    :
    :
    : Hope this helps.
    :
    :
    :
    Thanks. It works now.

Sign In or Register to comment.