Could somebody show me my error in this line please?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Could somebody show me my error in this line please?

Post 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,
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

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

Post 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).
User avatar
GeertDD
Forum Contributor
Posts: 274
Joined: Sun Oct 22, 2006 1:47 am
Location: Belgium

Post 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).
Post Reply