1

I am loading my stylesheets from my DB, kind my own interesting attempt at building a CMS. Anyways I am currently doing this by calling the styles in the head section of my main.php in my layout. This is the Yii framework btw. It's very strange because this worked for about 10 hours and then all of a sudden stopped being accepted. I am thinking it may be a bad value in the database that is throwing the stylesheets off but they all seem to load correctly when i preview the html. Here is my code;

I have narrowed it down to this line is somehow causing the error (which php will not report on) but I can't figure out why:

     echo $valueStrip.":".$cssAttrib->$value2.";";

here is the rest of the code so you can make sense of it:

$sql = 'Select selector from tbl_css t';

$css= Yii::app()->db->createCommand($sql)->queryAll();
$cssCols = new Css;
$cssColsAr = $cssCols->attributeLabels('');

foreach($css as $key => $value)
{

    foreach($cssColsAr as $key2 => $value2)
    {
        $cssAttrib = Css::model()->find('selector=:selector', 
                                  array(':selector'=>$value['selector']));
        $valueStrip = $value2;
        $valueStrip = str_replace('_','-',$value2);
        if ($valueStrip == 'id')
        {
            $value2 = 'color';
        }
        if ($valueStrip == 'selector')
        {
            $value2 = 'color';
        }
        echo "<style>";
        echo $value['selector']."{";
        echo $valueStrip.":".$cssAttrib->$value2.";";
        echo "}</style>";
    } 
}

here's an example of the generated styles:

<style>body{color:white;}</style>
<style>body{margin:0 px auto;}</style>

etc... I see no reason for it to crash?

error logs for apache:

[Sun May 05 14:53:45.529008 2013] [core:notice] [pid 4768:tid 412] AH00094: Command line: 'c:\\wamp\\bin\\apache\\apache2.4.2\\bin\\httpd.exe -d C:/wamp/bin/apache/apache2.4.2'
[Sun May 05 14:53:45.529008 2013] [mpm_winnt:notice] [pid 4768:tid 412] AH00418: Parent: Created child process 1248
[Sun May 05 14:53:46.059409 2013] [mpm_winnt:notice] [pid 1248:tid 288] AH00354: Child: Starting 64 worker threads.
[Sun May 05 14:59:38.304126 2013] [:error] [pid 1248:tid 796] [client 127.0.0.1:49410] PHP Warning:  require_once(C:\\wamp\\www\\blog/../../framework/yii.php): failed to open stream: No such file or directory in C:\\wamp\\www\\blog\\index.php on line 10
[Sun May 05 14:59:38.304126 2013] [:error] [pid 1248:tid 796] [client 127.0.0.1:49410] PHP Stack trace:
[Sun May 05 14:59:38.304126 2013] [:error] [pid 1248:tid 796] [client 127.0.0.1:49410] PHP   1. {main}() C:\\wamp\\www\\blog\\index.php:0
[Sun May 05 14:59:38.304126 2013] [:error] [pid 1248:tid 796] [client 127.0.0.1:49410] PHP Fatal error:  require_once(): Failed opening required 'C:\\wamp\\www\\blog/../../framework/yii.php' (include_path='.;C:\\php\\pear') in C:\\wamp\\www\\blog\\index.php on line 10
[Sun May 05 14:59:38.304126 2013] [:error] [pid 1248:tid 796] [client 127.0.0.1:49410] PHP Stack trace:
[Sun May 05 14:59:38.304126 2013] [:error] [pid 1248:tid 796] [client 127.0.0.1:49410] PHP   1. {main}() C:\\wamp\\www\\blog\\index.php:0
[Sun May 05 15:07:03.154570 2013] [:error] [pid 1248:tid 788] [client 127.0.0.1:49423] PHP Parse error:  syntax error, unexpected '*', expecting ')' in C:\\wamp\\www\\tblog\\protected\\config\\main.php on line 62
[Sun May 05 15:07:03.154570 2013] [:error] [pid 1248:tid 788] [client 127.0.0.1:49423] PHP Stack trace:
[Sun May 05 15:07:03.154570 2013] [:error] [pid 1248:tid 788] [client 127.0.0.1:49423] PHP   1. {main}() C:\\wamp\\www\\tblog\\index.php:0
[Sun May 05 15:07:03.154570 2013] [:error] [pid 1248:tid 788] [client 127.0.0.1:49423] PHP   2. YiiBase::createWebApplication() C:\\wamp\\www\\tblog\\index.php:13
[Sun May 05 15:07:03.154570 2013] [:error] [pid 1248:tid 788] [client 127.0.0.1:49423] PHP   3. YiiBase::createApplication() C:\\wamp\\www\\yii\\framework\\YiiBase.php:98
[Sun May 05 15:07:03.154570 2013] [:error] [pid 1248:tid 788] [client 127.0.0.1:49423] PHP   4. CApplication->__construct() C:\\wamp\\www\\yii\\framework\\YiiBase.php:125

php error log is blank

4

2 回答 2

1

仔细查看您的 apache 日志:

[Sun May 05 15:07:03.154570 2013] [:error] [pid 1248:tid 788] [client 127.0.0.1:49423] PHP Parse error:  syntax error, unexpected '*', expecting ')' in C:\\wamp\\www\\tblog\\protected\\config\\main.php on line 62

您只需C:\wamp\www\tblog\protected\config\main.php在第 62 行更正此语法错误即可。

于 2013-05-06T06:48:27.137 回答
0

Turns out the actual problem was a bad value in my Css model for opacity. Apparently 1.0 isn't accepted. I guess I will have to incorporate some validation for my CSS model based on proper rules for each property when I get the chance. I am still going to accept soju's answer, as proper error checking is a must! Thanks all!

于 2013-05-07T00:22:26.650 回答