MDanz Posted November 28, 2009 Share Posted November 28, 2009 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 More sharing options...
Goldeneye Posted November 28, 2009 Share Posted November 28, 2009 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 More sharing options...
MDanz Posted November 28, 2009 Author Share Posted November 28, 2009 thanks found the problem... its with LIMIT.. missed the T Link to comment https://forums.phpfreaks.com/topic/183250-css-and-php-problem/#findComment-967157 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.