img src - parse error

A

Anonymous

Guest
Hi guys,

can u guys help me to check whats wrong with my code.. i am having parse error on this code.

my code:
$username = $_SESSION['username'];

$image = ''<img src=\"http://localhost/~user/shopping_cart1/'.$username.'/images/'.$gallery.'\"' width=\"160\" height=\"160\" border=\"0\">';

by the way, did i add the backslashes correctly ???

please advise.
 
Alicia said:
Hi guys,

can u guys help me to check whats wrong with my code.. i am having parse error on this code.
$image = ''<img src="http://localhost/~user/shopping_cart1/'.$username.'/images/'.$gallery.'"' width="160" height="160" border="0">';

Code:
$image = "<img src="http://localhost/~user/shopping_cart1/".$username."/images/".$gallery."" width="160" height="160" border="0">";
 
Heredoc eliminates the possibility of parsing variables within the string. Here's how, IMO, it ought to be done:

Code:
$image = '<img src="http://localhost/~user/shopping_cart1/' . $username . '/images/' . $gallery . '" width="160" height="160" border="0">';

Why are people so phobic of whitespace? I always see people cramming everyhting together, no spaces between strings or numbers operators or anything. Whitespace is good, people!
 
Back
Top