found a couple of answers here on StackOverflow and used them as my models, but I have to miss something. I am trying to set a couple of background colors dynamically in CSS based on what is in my database, but it does not work - when I check the Inspect Element element in Chrome, the background color has a line through it and a warning sign for "Invalid property value.
Here is my code; it consists of two separate files: the first in the header file, and the second in the associated .php / css-esque file.
The title includes: [Edited 4/29 to include session code]
session_start();
if (!isset($_SESSION['email'])) {
header("Location: bad_login.php");
exit();
}
$_SESSION['companyid'] = $_POST['companyid'];
$companyID = $_SESSION['companyid'];
$email = $_SESSION['email'];
require_once('../includes/_connection.inc.php');
$connect = dbConnect('read');
$sql = 'SELECT colorone, colortwo, logo
FROM companies
WHERE companyid = ' . $companyID;
$result = $connect->query($sql) or die(mysqli_error());
$row = $result->fetch_assoc();
$colorOne = '#' . $row['colorone'];
$colorTwo = '#' . $row['colortwo'];
$carrierLogo = '/companylogos/' . $row['logo'];
PHP / CSS file:
<?php header("Content-type: text/css");
?>
width: 85%;
margin: 0 auto;
padding: 0.75em 0;
}
width: 100%;
height: 12px;
background-color: <?php echo $colorOne; ?>;
}
width: 100%;
height: 7px;
background-color: <?php echo $colorTwo; ?>;
}
EDIT 4/29:
This is the generated CSS:
#main {
width: 85%;
margin: 0 auto;
padding: 0.75em 0;
}
#colorOne {
width: 100%;
height: 12px;
background-color: ;
}
#colorTwo {
width: 100%;
height: 7px;
background-color: ;
}
html, , -. css.php?
CSS/PHP :
<link type="text/css" rel="stylesheet" href="../css/carrier.php">