The space goes away

my variable seems to lose a " " when I do this

$message .= "<td>Venue</td><td><input type='text' name='venue' value='$venue'></td>";

its output is

the source is

<td>Venue</td><td><input type='text' name='venue' value='car
anggie'></td>

but when I do

var_dump($venue);

The output is
“car anggie” string(1814)

Do you see what happened to the space?

Thanks…

That is not a space. It is a CR; which cannot be displayed in the input field.

1 Like

Is CR a carriage return?
Why does it show the variable as 2 words (on one line separated by a space) when I dump it?
But it comes out as one long word when I try & put it in an input box. I dont see why the CR replaces the space then

He answered that, it is because it is a carriage return. When you dump it and view the source, is it on two lines like so?

car
anggie

gosh, this is a strange error, I have

var_dump($city);
var_dump($length);
var_dump($venue);

which produces the source

string(9) "San Diego"
string(10) "30 minutes"
string(10) "Motel Room"

Everything looks good at this point, but now when I go

$message .= '<td>City</td><td><input type="text" name="city" value='.$city.'></td>';
...
$message .= "<td>Venue</td><td><input type='text' name='venue' value='$venue'></td>";
$message .= "<td>Length</td><td><input type='text' name='length' value='$length'></td>";

It produces the source,

<td>City</td><td><input
type="text" name="city" value=San Diego>
...
<td>Venue</td><td><input
type='text' name='venue' value='Motel
Room'></td><td>Length</td><td><input type='text' name='length'
value='30 minutes'>

the city variablreis formatted right, but why is it not in quotes?
where did the CR come from in venue?
how is this right? isnt it the same as above

how do I place a CR in the source only? (so I can give every & its own line?

Because you left them out of the code

value='.$city.'

needs to be

value="'.$city.'"

but when I make that change, a mystery CR appears

<td>City</td><td><input
type="text" name="city" value="San
Diego"></td>

How can I get each td on it own line?

Try setting the width to <td style="width:42em;">.

If that works then check your style sheet otherwise var_dump( $city );

While it might not be relevant to the data shown, is there any reason you’re being inconsistent with the use of single vs. double quotes for the html tags? I know that using double quotes in the php means that you can just stick variable names in line without having to break out of the quotes, it just makes my eyes go funny when trying to figure out if there’s an imbalance. And are you checking somewhere that none of your values contain single quotes?

What happens if you var_dump($message) when you’ve finished building it? In your first example, why was the string showing as 1814 characters long?

I’m assuming you mean in the source rather than when you display the web page? Can you add a “\n” on the end of each time you add a line to $message? I’ve never tried it as the format of the html doesn’t really matter if it’s correct, save for some old browsers reacting badly to white space as I recall.

1 Like

thanks…
that was the deal, the problem went away when I used "

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.