我沒有什麼問題,連接到style.php DBCSS在PHP與MySQL
<?php
$servername = "localhost";
$username = "root";
$password = "";
$conn = new mysqli($servername, $username, $password);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
header("Content-type: text/css; charset: UTF-8");
$Color = "#000000";
$Test = "#555000";
?>
#header {
background-color: <?php echo $Test; ?>;
width: 500px;
height: 500px;
}
a{
color: <?php echo $Color; ?>;
}
這段代碼可以正常使用。 當我做這樣的事情:
<?php
header("Content-type: text/css; charset: UTF-8");
$Color = "#000000";
$Test = "#555000";
?>
#header {
background-color: <?php echo $Test; ?>;
width: 500px;
height: 500px;
}
a{
color: <?php echo $Color; ?>;
}
這裏的#header {}這是不行的,但一個{}將工作。 我可以以某種方式使它工作?
做過任何基本的調試,像打直接兩個版本的網址是什麼? db版本可能會輸出一些東西\在css的東西開始前,所以生成的輸出是'foo#header',而不是'#header'。 –