Jump to content

PHP Echo Problem


Rustywolf

Recommended Posts

I have the following code:

 

echo '<img src='	. $row[map] . '>';
echo '<img class="' . $row[username] . '" src="' . $row[figure] . '" >';
echo '<style type="text/css">';
echo '.' . $row[username];
echo '{';
echo "top: " . $row[ypos] * 35 + $row[ypos] * 2 + 2 . ';';
echo "left: "	.  $row[xpos] * 30 + $row[xpos] * 2 + 2 . ';';
echo '}';	
echo '</style>';

 

(I know its not the best code but i will be cleaning it up after)

 

 

Buy for some reason, i get this as my page source:

<img src=./images/maps/testmap.png><img class="Rusty" src="./images/mage_white.png" ><style type="text/css">.Rusty{2;2;}</style>

 

Why wont "Top: " and "Left: " echo?

Link to comment
https://forums.phpfreaks.com/topic/196949-php-echo-problem/
Share on other sites

It's got something to do with the evaluation of the expression being concatenated within the string. The following corrects the problem -

 

echo '<img src='. $row[map] . '>';
echo '<img class="' . $row[username] . '" src="' . $row[figure] . '" >';
echo '<style type="text/css">';
echo '.' . $row[username];
echo '{';
echo "top: " . ($row[ypos] * 35 + $row[ypos] * 2 + 2) . ';';
echo "left: " .  ($row[xpos] * 30 + $row[xpos] * 2 + 2) . ';';
echo '}';
echo '</style>';

Link to comment
https://forums.phpfreaks.com/topic/196949-php-echo-problem/#findComment-1033959
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.