echo "<head></head><div style='float:left; padding:30px'><h1>$k['Name']</h1></br><img src='sponsor/".$k['Pic'].'.jpeg'."' height='300' width='300'><br>.</hr></div>";

The error occured after i wanted to echo $k['Name'];

This is the error that it shows
Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)

Recommended Answers

All 3 Replies

Member Avatar for diafol

Either concatenate the first variable or use braces to surround it. Concatenation is such a mess

In any case, this is HTML code, not PHP. You can put HTML in PHP class member variables and then output them in one shot, and this error should not occur. Do remember you still need to express the HTML code properly in the PHP variable.

Member Avatar for diafol
echo "<head></head><div style='float:left; padding:30px'><h1>{$k['Name']}</h1></br><img src='sponsor/{$k['Pic']}.jpeg' height='300' width='300'><br></hr></div>";

Should work using braces. Use braces if you want to use array elements or class properties in strings but only if the string is enclosed in double quotes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.