...

View Full Version : CSS style written by PHP doesn't work!



sam9461
01-20-2012, 01:07 AM
Hi, experts, help please, thank you so much.

I wrote css style for an image by PHP, as follows:

<img src="<?php echo "/images/prizes/".$_SESSION['imgForPrizes'][$key1]; ?>" >

It's working , and fine.


However, if I want the image as a background, and wrote as below:

<.... style="background:url(“<?php echo “/images/prizes/”.$_SESSION['imgForPrizes'][$key1]; ?>”) no-repeat center; ">

It's not working, the image doesn't show on the web page.

Could experts help me to sort the problem out?

Thank you!

felgall
01-20-2012, 01:38 AM
Are the invalid characters in “<?php echo “/images/prizes/”.$_SESSION['imgForPrizes'][$key1]; ?>” actually there or are they really " that have been accidentally converted to invalid characters when you copied them to the forum?

If they are actually " and not invalid angled quotes then have you tried viewing the source of the page to see what code is being generated by the PHP when someone views the page?

sam9461
01-20-2012, 01:44 PM
Felgall, thanks,

I've sort it out, by removing " " between ( and <, then it is working.



<.... style="background:url(<?php echo “/images/prizes/”.$_SESSION['imgForPrizes'][$key1]; ?>) no-repeat center; ">



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum