Page 1 of 1

Could somebody show me my error in this line please?

Posted: Sun Nov 12, 2006 8:30 am
by impulse()

Code: Select all

echo "<input type = 'text' name = 'changeName' value = '$r['customername']'>";
$r['customername'] is retreived from a DB

I'm hoping to put the text from a DB entry into a text field.

Regards,

Re: Could somebody show me my error in this line please?

Posted: Sun Nov 12, 2006 8:49 am
by timvw
impulse() wrote:

Code: Select all

echo "<input type = 'text' name = 'changeName' value = '$r['customername']'>";
Find the answer yourself: http://be2.php.net/string (Hint: Have a look at the complex/curly syntax examples).

Posted: Sun Nov 12, 2006 9:25 am
by GeertDD
To keep it simple I prefer to always exclude variables from a string.

Code: Select all

echo '<input type="text" name="changeName" value="'. $r['customername'] .'">';
Not only improves syntax highlighting in my text editor, but should be just a bit faster as well (although I've heard people proclaiming that's only a myth).