Jump to content

css and php problem...


MDanz

Recommended Posts

when i do this, the whole page become blank, when i remove it the page functions again.. i can't spot whats wrong...

 

 <style type="text/css">
.stacktemp a {
display: block;


width: 101px;
height: 57px;

background: url("<?php 

mysql_connect("localhost", "Master", "pword");
mysql_select_db("Login");

$salute = mysql_query("SELECT * FROM messages WHERE to_user = '$_SESSION[username]' ORDER by id DESC LIMI 1")or die(mysql_error());
while($record = mysql_fetch_array($salute))
{ 
$new = $record['new'];
}
if ($new=="0") {

$template = "http://www.testing.com/templatesmallnew.jpg";
} else

{
$template = "http://www.testing.com/templatesmall.jpg";
}


echo "$template"; ?>");
}</style>

Link to comment
https://forums.phpfreaks.com/topic/183250-css-and-php-problem/
Share on other sites

It's simple -- you can't put an entire PHP script inside a CSS background-property.

 

You have to do something like this instead:

<?php 

mysql_connect("localhost", "Master", "pword");
mysql_select_db("Login");

$salute = mysql_query("SELECT * FROM messages WHERE to_user = '$_SESSION[username]' ORDER by id DESC LIMI 1")or die(mysql_error());
while($record = mysql_fetch_array($salute))
{ 
$new = $record['new'];
}
if ($new=="0") {

$template = "http://www.testing.com/templatesmallnew.jpg";
} else

{
$template = "http://www.testing.com/templatesmall.jpg";
}
?>

<style type="text/css">
.stacktemp a {
display: block;


width: 101px;
height: 57px;

background: url(<?php $template; ?>);
}
</style>

Link to comment
https://forums.phpfreaks.com/topic/183250-css-and-php-problem/#findComment-967156
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.