ktrollinger Posted July 7, 2007 Share Posted July 7, 2007 Hi - trying to use an inline style to dynamically place a background image - then use html text on top of that image for higher SEO/ Google Quality score. Tried escaping with no luck Working hard-coded example: background-image: url(images/Bar_Chair_only.jpg); Tested and no work version: <style type="text/css"> <!-- .product_bg_img { background-image: url(/images/<\?php echo \$row_qProduct\['Large_Image'\]; \?>); background-repeat: no-repeat; } --> </style> Any help appreciated. Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted July 7, 2007 Share Posted July 7, 2007 Give this a try: <?php $image = "/images/$row_qProduct['Large_Image']"; ?> <style type="text/css"> <!-- .product_bg_img { background-image: url("<?php echo $image; ?>"); background-repeat: no-repeat; } --> </style> Quote Link to comment Share on other sites More sharing options...
ktrollinger Posted July 7, 2007 Author Share Posted July 7, 2007 Thanks - got an error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING Any thoughts? Again Thanks for the help. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 7, 2007 Share Posted July 7, 2007 got a line number on the error? try $image = "/images/".$row_qProduct['Large_Image']; Quote Link to comment Share on other sites More sharing options...
ktrollinger Posted July 8, 2007 Author Share Posted July 8, 2007 Thanks Looks very close - though the extra "/images/" piece is killing me. My bad, though. . .the path is in the <?php echo $image; ?> so i am getting doubled - as in /images/images/xxxx.jpg I tried removing the "/images/" and couple other things with no luck. Thanks. Quote Link to comment Share on other sites More sharing options...
ktrollinger Posted July 8, 2007 Author Share Posted July 8, 2007 Solved! back slash before the "?php echo $image; ?>" did the trick <?php $image = $row_qProduct['Large_Image']; ?> <style type="text/css"> <!-- .product_bg_img { background-image: url("/<?php echo $image; ?>"); background-repeat: no-repeat; } --> </style> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.