Here is the line that is effecting my site from loading...I am just getting a blank page for my site. Please help as my business site is obviously down. Thank you in advance to whomever can help me.
$bg = (!$bgimage == '') ? 'style="background-image:url'("".$bgimage[url].'")' : '';
Here is the line that is effecting my site from loading...I am just getting a blank page for my site. Please help as my business site is obviously down. Thank you in advance to whomever can help me.
$bg = (!$bgimage == '') ? 'style="background-image:url'("".$bgimage[url].'")' : '';
Share Improve this question asked Feb 13, 2022 at 21:20 Steve BonillaSteve Bonilla 11 Answer
Reset to default 0Your code:
$bg = (!$bgimage == '') ? 'style="background-image:url'("".$bgimage[url].'")' : '';
There's a confusion with the quote marks. You're closing your '
too early, but it's really hard to see in a construction like this. (Also, the array index needs to be wrapped in quotes, either single or double.)
$bg = (!$bgimage == '') ? 'style="background-image:url("'.$bgimage['url'].'")' : '';
might clear up the PHP error, but I'm not sure it'll still do what you want it to. There's still some confusion with quote marks in the CSS; also, is $bgimage
a string or an array?
I'd recommend not using the ternary operator, in this case, to make the code more readable.
$bg = '';
if ( ! empty( $bgimage ) ) {
$bg = 'style="background-image:url(\'' . $bgimage['url'] . '\')";
}